码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-01-24 20:00:44      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:

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

 

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

标签:

原文地址:http://www.cnblogs.com/guofeng1022/p/4246343.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!