抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

题干

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.

还有另一类斐波那契数:F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2)。


Input

输入由一系列行组成,每一行包含一个整数n。1000000)。

Output

如果3人平均分成F(n),打印单词“yes”。

如果不是,打印单词“no”。

测试案例

Input

1
2
3
4
5
6
0
1
2
3
4
5

Output

1
2
3
4
5
6
no
no
yes
no
no
no

题意与思路

给定一个斐波那契数列: 求对于给定的 n 是否能整除 3

由于斐波那契数列的递推关系是加法,因此其对 3 的整除性 也具有加法的递推关系 手推几项找规律: $$

$$ 可以看出,,此后

周期为 8,当且仅当


题解

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <cstdio>
using namespace std;

int n;

int main(){
while (scanf("%d", &n) != EOF){
if(n % 8 == 2 || n % 8 == 6)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}

return 0;
}

评论