| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
只要将HDOJ1028的代码稍微改下就好~水~【附代码】/*
POJ 1664
@author: NGUper
这个放苹果的问题其实和HDU 1028很相似
*/
#include <iostream>
#include <cstdio>
using namespace std;
const int Max = 10 + 5;
int main()
{
int n;
int f[Max][Max];
//先进行预处理
f[0][0] = f[1][1] = 1;
for(int i=2; i<=Max-1; i++)
{
f[i][1] = 1;
for(int j=2; j<=i; j++)
{
int k;
if(i-j < j) //注意考虑m>n的情况!
{
k = i-j;
}
else
{
k = j;
}
f[i][j] = f[i-j][k] + f[i][j-1];
}
}
int t;
scanf("%d",&t);
while(t--)
{
int n,m;
scanf("%d %d",&n,&m);
cout<<f[n][m]<<endl;
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator