POJ1579
来源:互联网 发布:ppt圆环图编辑数据 编辑:程序博客网 时间:2024/06/09 13:08
水题,没看到半点dp的影子.强行算是DP的话,公式已经给出来了,直接写就行了.
#include <iostream>#include <cstring>#include <cstdio>using namespace std;int dp[25][25][25];int main(){ int i,j,k; memset(dp,0,sizeof(dp)); for(i=0;i<=20;i++) { for(j=0;j<=20;j++) { dp[0][i][j]=1; dp[i][0][j]=1; dp[i][j][0]=1; } } dp[1][1][1]=0; for(i=1;i<=20;i++) { for(j=1;j<=20;j++) { for(k=1;k<=20;k++) { int tem; if(i<j&&j<k) { tem=dp[i][j][k-1]+dp[i][j-1][k-1]-dp[i][j-1][k]; dp[i][j][k]=tem; } else { tem=dp[i-1][j][k]+dp[i-1][j-1][k]+dp[i-1][j][k-1]-dp[i-1][j-1][k-1]; dp[i][j][k]=tem; } } } } //cout<<"YES"<<endl; while(true) { int a,b,c; cin>>a>>b>>c; if(a==-1&&b==-1&&c==-1) break; cout<<"w("<<a<<", "<<b<<", "<<c<<") = "; if(a<=0||b<=0||c<=0) { cout<<1<<endl; continue; } if(a>20||b>20||c>20) { cout<<dp[20][20][20]<<endl; continue; } cout<<dp[a][b][c]<<endl; } return 0;}
0 0
- poj1579
- poj1579
- poj1579
- poj1579
- POJ1579
- poj1579
- poj1579解题报告
- poj1579 递推
- 北大ACM poj1579
- poj1579 Function Run Fun
- POJ1579:Function Run Fun
- POJ1579-记忆化搜索
- [水]ZOJ1168 || POJ1579
- POJ1579.Function Run Fun
- POJ1579:dfs+记忆
- POJ1579简单dp
- Function Run Fun poj1579
- POJ1579 HDOJ1579 Function Run Fun
- JAVA 学习第五天(3) 访问权限
- 利用PHPexcel将excel表导入mysql数据库
- hdu 1014
- nginx.conf文件参数分析
- 欧拉工程第29题:Distinct powers
- POJ1579
- LeetCode 3 Longest Substring Without Repeating Characters
- iOS URL schemes
- 模板函数多个类型参数时候怎么调用
- heroku部署java web项目
- Linked List Cycle —— Leetcode
- android 防止对控件的重复点击和同时点击多个控件
- SDUT 2605 A^X mod P
- maven安装相关