标签:bsp return style 多个 content 超过 include 8 8 ret
1 #include <stdio.h> 2 3 int c1,c2,n; 4 int w[11]; 5 int cw,bestw,r; 6 7 8 9 void backtack(int i) 10 { 11 if(i>n) 12 { 13 if(cw>bestw) 14 { 15 bestw = cw; 16 } 17 return ; 18 } 19 r-=w[i]; 20 if(cw+w[i]<=c1) 21 { 22 cw+=w[i]; 23 backtack(i+1); 24 cw-=w[i]; 25 } 26 if(cw+r>bestw) 27 { 28 backtack(i+1); 29 } 30 r+=w[i]; 31 } 32 33 int main() 34 { 35 while(scanf("%d%d%d",&c1,&c2,&n)!=0&&n!=0) 36 { 37 cw=0,bestw=0,r=0; 38 int i; 39 for(i=1;i<=n;i++) 40 { 41 scanf("%d",&w[i]); 42 r+=w[i]; 43 } 44 backtack(1); 45 if(r-bestw<=c2) 46 printf("Yes\n"); 47 else 48 printf("No\n"); 49 } 50 return 0; 51 }
标签:bsp return style 多个 content 超过 include 8 8 ret
原文地址:https://www.cnblogs.com/kmxojer/p/9941109.html