HDU1028 Ignatius and the Princess III

代码

 1 #include<cstdio>
 2 #include<algorithm>
 3 #include<iostream>
 4 
 5 using namespace std;
 6 
 7 int a[130],b[130]; 
 8 
 9 int main() {
10     int n;
11     while (~scanf("%d",&n)) {
12         for (int i=0; i<=n; ++i) {
13             a[i] = 1;b[i] = 0;
14         }
15         for (int i=2; i<=n; ++i) {
16             for (int j=0; j<=n; ++j) 
17                 for (int k=0; k+j<=n; k+=i) 
18                     b[j+k] += a[j];
19             for (int j=0; j<=n; ++j) {
20                 a[j] = b[j];b[j] = 0;
21             }
22         }
23         printf("%d\n",a[n]);
24     }
25     return 0;
26 }
View Code

相关文章:

  • 2022-12-23
  • 2022-01-20
  • 2021-12-12
  • 2022-03-08
猜你喜欢
  • 2021-05-28
  • 2022-12-23
  • 2022-12-23
  • 2021-06-08
  • 2022-12-23
  • 2021-07-20
  • 2022-12-23
相关资源
相似解决方案