问题描述
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
算法
方法一:如果先求f(n),再判断是否能整除3,行不通,因为当n在150左右时,f(n)已经无法用64位整数保存了。f(n)实在太大了。所有,此法不可行。
方法二:我想此类题目结果一般有规律,然后就将前100个结果打印出来。发现当(i-2)%4==0时,输出yes,其余都是no。试了一下,就A了。
AC代码
#include<stdio.h>
int main()
{