斐波那契的递推;
有规律,但是我打表过了;
f[0]=7;
f[1]=11;
实际对他们%3 就是 f[0]=1. f[1]=2;正规的斐波那契了;
则有n>2 f[n]=(f[n-1]+f[n-2])%3;
递推出斐波那契数列;
则问输入n,f[n]%3==0 yes . 否则 no;
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.
Print the word "no" if not.
Sample Input
0 1 2 3 4 5
#include <bits/stdc++.h>
using namespace std ;
long long dp[10000000];
int main()
{
dp[0]=7%3;
dp[1]=11%3;
for(int i = 2;i<=1000000;i++)
{
dp[i]=(dp[i-1]+dp[i-2])%3;
}
int n ;
while(cin>>n)
{
if(dp[n]%3==0) printf("yes\n");
else printf("no\n");
}
return 0 ;
}