There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).
#include <iostream>
#include <cstdio>
const int N=1000000+5;
using namespace std;
long long f[N];
int main()
{
int n;
f[0]=7%3;
f[1]=11%3;
for(int i=2;i<=1000000;i++)
f[i]=(f[i-1]+f[i-2])%3;
while(scanf("%d",&n)!=EOF)
{
if(f[n]==0)
printf("yes\n");
else
printf("no\n");
}
return 0;
}
该程序计算了一种特殊的斐波那契数列,其中F(0)=7,F(1)=11,并且后续项通过F(n)=F(n-1)+F(n-2)递推。它使用模3运算来存储和输出序列的值,最后根据输入的n判断F(n)是否等于0并输出结果。
417

被折叠的 条评论
为什么被折叠?



