CDZSC_2015寒假新人(2)——数学 D

D - D
Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u
Submit Status

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
 

 

 
 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 #include<ctime>
 5 using namespace std;
 6 int a[1000010];
 7 int main()
 8 {
 9     a[0]=7;
10     a[1]=11;
11     for(int i=2;i<1000000;i++)
12     {
13         a[i]=(a[i-1]+a[i-2])%3;
14     }
15     int n;
16     //printf("%.2f",(double)clock()/CLOCKS_PER_SEC);
17     while((scanf("%d",&n))!=EOF)
18     {
19         if(a[n]%3==0)
20         {
21         printf("yes\n");
22         }
23         else
24         {
25             printf("no\n");
26         }
27     }
28 }
View Code

 

posted on 2015-01-24 19:43  学习编程的峰峰  阅读(159)  评论(0编辑  收藏  举报

导航