POJ 1664 放苹果
Posted Christopher Yan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了POJ 1664 放苹果相关的知识,希望对你有一定的参考价值。
递推,放苹果
1 #include <algorithm> 2 #include <iostream> 3 #include <cstring> 4 #include <cstdio> 5 #include <cctype> 6 7 using namespace std; 8 9 inline void read(long long &x) 10 { 11 int k = 1; x = 0; 12 char c = getchar(); 13 while (!isdigit(c)) 14 if (c == ‘-‘) k = - 1, c = getchar(); 15 else c = getchar(); 16 while (isdigit(c)) 17 x = (x << 1) + (x << 3) + (c ^ 48), 18 c = getchar(); 19 x *= k; 20 } 21 22 long long T, n, m, dp[55][55]; 23 24 int main() 25 { 26 read(T); 27 for (int i = 1; i <= 50; ++i) 28 for (int j = 0; j <= 50; ++j) 29 if (i == 1 || j == 0) dp[i][j] = 1; 30 else if (i > j) dp[i][j] = dp[j][j]; 31 else if (i <= j) dp[i][j] = dp[i][j - i] + dp[i - 1][j]; 32 for (int plk = 1; plk <= T; ++plk) 33 read(n), read(m), printf("%d ", dp[m][n]); 34 return 0; 35 }
以上是关于POJ 1664 放苹果的主要内容,如果未能解决你的问题,请参考以下文章