http://acm.hdu.edu.cn/showproblem.php?pid=10Fibonacci的兔子問題要改了,mod 3的遞推數列肯定得有循環節吧,把第一個循環找到,
{1,2,0,2,2,1,0,1},恰好是從第一位開始,OK:
#include<stdio.h>
int main()
{
int n,f[8]={1,2,0,2,2,1,0,1};
while (scanf("%d",&n)!=-1)
{
if (f[n%8]==0)
printf("yes\n");
else
printf("no\n");
}
}
ps:水題啊水題嘛。