Advertisement
Guest User

Untitled

a guest
May 19th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. /*-----------------
  2. * author: Rainboy
  3. * email: rainboylvx@qq.com
  4. * time: 2019年 05月 19日 星期日 17:06:26 CST
  5. * problem:  luogu-2347
  6. *----------------*/
  7. #include <cstdio>
  8. #include <cstring>
  9. #include <algorithm>
  10. using namespace std;
  11.  
  12. int a[10];
  13. int f[1005] = {0};
  14. int w[10] = {0,1,2,3,5,10,20};
  15.  
  16. int main(){
  17.     int i,j,k;
  18.     for (i=1;i<=6;i++){
  19.         scanf("%d",&a[i]);
  20.     }
  21.     f[0] =1;
  22.  
  23.     int cnt = 0;
  24.     for(i=1;i<=6;i++)
  25.         for(j=1;j<=a[i];j++){
  26.             for(k=1000;k>=w[i];k--){
  27.                 if( f[k] == 0 && f[k-w[i]] ==1){
  28.                     f[k] = 1;
  29.                     cnt++;
  30.                 }
  31.             }
  32.         }
  33.     printf("Total=%d\n",cnt);
  34.  
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement