There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).
Print the word "no" if not.
0 1 2 3 4 5
no no yes no no no
思路 若暴力求解,一定会超出longlong 的范围,求一个规律。
从图可得 8个是一个循环。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
int m;
int f[8]={1,2,0,2,2,1,0,1};
while(~scanf("%d",&m))
{
int n=f[m%8];
if(n!=0)
printf("no\n");
else
printf("yes\n");
}
return 0;
}