P2347 砝码称重

https://www.luogu.org/problemnew/show/P2347

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <bits/stdc++.h>
using namespace std;

int num[] = {0,1,2,3,5,10,20};
int n[7],ans;
bool tong[1001];

int main(void)
{
for(int i = 1;i <= 6;++i)
cin >> n[i];

tong[0] = 1;

for(int i = 1;i <= 6;++i)
for(int j = 1;j <= n[i];++j)
for(int q = 1000;q >= 0;--q)
{
if(tong[q])
tong[q + num[i]] = 1;
}

for(int i = 1;i <= 1000;++i)
if(tong[i]) ans++;

cout << "Total=" << ans;

return 0;
}
本站文章除注明转载外均为原创,未经允许不要转载哇. ヾ(゚ー゚ヾ) http://chicago01.top/2019/05/14/p2347-fa-ma-cheng-chong/index.html
Compartir