标签:des style blog io color ar for sp div
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
1 #include <stdio.h> 2 3 int calculate_Fn(int number); 4 5 int main(){ 6 int number; 7 8 while((scanf("%d",&number))!=EOF){ 9 if(calculate_Fn(number)==0) 10 printf("yes\n"); 11 12 else 13 printf("no\n"); 14 } 15 return 0; 16 } 17 18 int calculate_Fn(int number){ 19 int i; 20 int result; 21 int temp; 22 int a=7; 23 int b=11; 24 25 if(number==0) 26 return a; 27 28 else if(number==1) 29 return b; 30 31 for(i=2;i<=number;i++){ 32 result=(a%3+b%3)%3; 33 34 temp=b; 35 b=result; 36 a=temp; 37 } 38 39 return result; 40 }
标签:des style blog io color ar for sp div
原文地址:http://www.cnblogs.com/zqxLonely/p/4054492.html