Fibonacci Again 分类: HDU 2015-06-26 11:05 13人阅读 评论(0) 收藏

时间:2021-11-24 02:40:58

Fibonacci Again

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 43539 Accepted Submission(s): 20797

Problem Description

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

Input

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

Output

Print the word “yes”

if 3 divide evenly into F(n).

Print the word “no” if not.

Sample Input

0

1

2

3

4

5

Sample Output

no

no

yes

no

no

no

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath> using namespace std; const int Max=1100000;
int Arr[Max];
int main()
{
memset(Arr,0,sizeof(Arr));
Arr[0]=1;
Arr[1]=2;
for(int i=2;i<Max;i++)
{
Arr[i]=(Arr[i-1]+Arr[i-2])%3;
}
int n;
while(~scanf("%d",&n))
{
if(!Arr[n])
{
printf("yes\n");
}
else
{
printf("no\n");
} }
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。