POJ 1243
1 #include <iostream> 2 #include <algorithm> 3 #include <cmath> 4 #define MAXN 50 5 using namespace std; 6 7 int dp[MAXN][MAXN]; 8 9 int main() 10 { 11 //freopen("acm.acm","r",stdin); 12 int g; 13 int l; 14 int i; 15 int j; 16 int time = 0; 17 18 while(cin>>g>>l) 19 { 20 dp[0][0] = 1; 21 if(g == 0 && l == 0) 22 { 23 break; 24 } 25 for(i = 0; i <= g; ++ i) 26 { 27 dp[i][0] = i; 28 } 29 for(i = 0; i <= g; ++ i) 30 { 31 for(j = 0; j <= l; ++ j) 32 { 33 if(j >= i) 34 { 35 dp[i][j] = pow((double)2,i)-1; 36 } 37 else 38 { 39 dp[i][j] = dp[i-1][j-1]+dp[i-1][j]+1; 40 } 41 } 42 } 43 cout<<"Case "<<++ time<<": "; 44 cout<<dp[g][l]<<endl; 45 } 46 }
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。
技术网站地址: vmfor.com