题目传送门
解题思路:
找出所有在1000内可以用给出数据的表示的量,数一数一共有几个即为答案
AC代码:
1 #include<iostream> 2 #include<cstdio> 3 4 using namespace std; 5 6 int a[7],v[] = {0,1,2,3,5,10,20},ans; 7 bool vis[1001]; 8 9 int main() { 10 for(int i = 1;i <= 6; i++) 11 scanf("%d",&a[i]); 12 vis[0] = 1; 13 for(int i = 1;i <= 6; i++) 14 for(int j = 1;j <= a[i]; j++) 15 for(int k = 1000;k >= 0; k--) 16 if(vis[k]) 17 vis[k+v[i]] = 1; 18 for(int i = 1;i <= 1000; i++) 19 if(vis[i]) ans++; 20 printf("Total=%d",ans); 21 22 return 0; 23 }
//NOIP提高1996 T4