简单DP,关系式出来后代码就很简洁,注意要用long long,刚开始我用的int果断WA,然后换成大数,后来看了看别人的代码long long竟然可以过,就又换成long long了。。几经周折
#include<stdio.h>
int main()
{
int i;
unsigned long long dp[62][3];
dp[0][0] = 1;
dp[0][1] = dp[0][2] = 0;
for (i = 1; i <= 61; i++)
{
dp[i][2] = dp[i - 1][0];
dp[i][1] = dp[i - 1][0] + dp[i - 1][1];
dp[i][0] = dp[i][1] + dp[i - 1][2];
}
while (scanf("%d", &i) != EOF)
printf("%llu\n", dp[i + 1][0]);
return 0;
}