**链接:****传送门 **
题意:现在给出 Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).问第 n 项能不能整除 3
思路:F(n) % 3 == 0 可以推导出 F(n) = ( F(n-1)%3 + F(n-2)%3 ) % 3 ,直接打个表判断 F(n) 是否为 0 即可
/*************************************************************************
> File Name: hdu1021.cpp
> Author: WArobot
> Blog: http://www.cnblogs.com/WArobot/
> Created Time: 2017年05月22日 星期一 10时51分29秒
************************************************************************/
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 1000010;
int f[MAX_N];
void init(){
f[0] = 7; f[1] = 11;
for(int i = 2 ; i < MAX_N ; i ++){
f[i] = ( f[i-1]%3 + f[i-2]%3 )%3;
}
}
int main(){
init();
int n;
while(~scanf("%d",&n)){
if( f[n] == 0 ) printf("yes
");
else printf("no
");
}
return 0;
}