Μῆτις -- chengfengYang_LMN

enjoy programming (๑•ᴗ•๑) status：百度(实习)

[1021]：Fibonacci Again

Fibonacci Again

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 46300 Accepted Submission(s): 22077

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<stdio.h>
#define F0 7
#define F1 11//题意给出的F(0) F(1)

int num;
int main()
{
while(scanf("%d", &num)!=EOF){
int a = F0%3, b = F1%3, n=2;
if(num==0 || num==1){
printf("no\n");
}
else{
for(; n<=num; n++){
int left = (a+b)%3;//①这一部分解释如图一
a = b;
b = left;
if(left%3==0 && n==num){
printf("yes\n");
}
else if(left%3!=0 && n==num){
printf("no\n");
}
}
}
}
return 0;
}

杭电水体--Fibonacci Again 1021

2013-06-01 13:47:01

hdu1021Fibonacci Again找规律

2015-08-14 09:02:17

hdu1021 Fibonacci Again(C语言）

2017-07-25 21:13:14

杭电1021——Fibonacci Again（找规律、简单题）

2015-11-01 14:53:59

Fibonacci again and again（hdu1848+SG打表）

2015-08-04 21:36:41

HDU ACM Fibonacci Again 解题报告

2014-10-06 21:47:18

ACM-SG函数之Fibonacci again and again——hdu1848

2014-05-03 08:58:08

HDUOJ 1021 Fibonacci Again

2015-07-19 20:29:56

HDOJ 1021 Fibonacci Again

2015-06-12 12:10:59

hdu 1021 - Fibonacci Again

2013-09-20 14:12:54

不良信息举报

[1021]：Fibonacci Again