uva 11137-Ingenuous Cubreency

5694 ワード


http://uva.onlinejudge.org/index.php?option=com_オンラインjudge&Itemid=8&page=show_problem&problem=2906
 
 
11137 - Ingenuous Cubreency Time limit: 3.000 seconds.
 
 
 
Problem I: Ingenuous Cubreency
 
ピープル in Cubeland アメリカ キュービック coins. Not only the ユニット 保存先 currency is caled acube but also the coins エリア sharped like キュベス and their values エリア cubes. Coins with values 保存先 all. キュービック numbers upする. ト 9261 (= 21^3) i.e. coins with the denominations 保存先 1, 8, 27, ..., upする. ト 9261 キュベス、 エリア available in Cubeland.
  uva 11137 - Ingenuous Cubrency
Your task is ト count the number 保存先 ways ト pay a. given グループ using キュービック coins 保存先 Cubeland. For example、 there エリア 3 ways ト pay 21 cubes: twenty one 1 cube coins、 or one 8 cube coin and thirteen 1 cube coins、 or two 8 cube coin and ファイブ 1 cube coins.
Input consists 保存先 ライン each containing an インテグ グループ ト be paid. You may asume that all. the amounts エリア positive and less than 10000.
For each 保存先 the given amounts ト be paid out put one ライン containing a. single インテグ representing the number 保存先 ways ト pay the given グループ using the coins available in Cubeland.
Sample input
10 
21
77
9999
Output for sample input
2
3
22
4400220018293
 
 
 
P. Rudnicki、 from folklore
 
 分析:
直接dp
 
 
 ACコード:
 1  

 2 

 3 // UVa11137 Ingenuous Cubrency

 4 

 5 #include<cstring>

 6 

 7 #include<iostream>

 8 

 9 using namespace std;

10 

11  

12 

13 long long d[30][10010];

14 

15 int main() {

16 

17   memset(d, 0, sizeof(d));

18 

19   d[0][0] = 1;

20 

21   for(int i = 1; i <= 25; i++)

22 

23     for(int j = 0; j <= 10000; j++) {

24 

25       d[i][j] = d[i-1][j];

26 

27       if(j>=i*i*i) d[i][j] += d[i][j-i*i*i];

28 

29     }

30 

31  

32 

33   int n;

34 

35   while(cin >> n) {

36 

37     cout << d[25][n] << endl;    

38 

39   }

40 

41   return 0;

42 

43 }

44 

45