标签:
Description
Input
Output
Sample Input
2934 12553
Sample Output
718831 13137761
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=32768+5;
int n;
int dp[maxn][5];
void init() {
memset(dp,0,sizeof(dp));
dp[1][1]=1;
dp[1][2]=1;
dp[1][3]=1;
dp[2][1]=1;
dp[2][2]=2;
dp[2][3]=2;
dp[3][1]=1;
dp[3][2]=2;
dp[3][3]=3;
for(int i=4;i<maxn;i++)
{
for(int j=1;j<=3;j++)
{
if(j==1)dp[i][j]=1;
else dp[i][j]=dp[i-j][j]+dp[i][j-1];
}
}
}
int main() {
init();
while(~scanf("%d",&n)) {
printf("%d\n",dp[n][3]);
}
return 0;
}版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/qq_18661257/article/details/46789891