Datahub
数据改变生活

1277: Fibonacci Again

发表时间:2022-10-27 19:28

1277: Fibonacci Again

时间限制: 1 Sec   内存限制: 128 MB

题目描述

There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2)

输入

Input consists of a sequence of lines, each containing an integer n. (n < 1,000,000)

输出

Print the word "yes" if 3 divide evenly into F(n).

Print the word "no" if not.

样例输入 Copy

0

1

2

3

4

5

样例输出 Copy

no

no

yes

no

no

no

#include<bits/stdc++.h>

using namespace std;

int main(){

int a[1000005];int cnt=2;

a[0]=7;a[1]=11;

for(;cnt<1000000;cnt++)

a[cnt]=(a[cnt-1]+a[cnt-2])%3;

cnt--;

// printf("%d\n",cnt);

int n;

while(scanf("%d",&n)!=EOF){

if(a[n]%3==0) printf("yes\n");

else printf("no\n");

}

return 0;

}


文章分类: 算法例题
分享到:
QQ:258506508                                     联系电话:020-000000    000-000000                                   联系邮箱:xxx@.co.m                                     联系地址:XXX省XXX市XXX县XXX路