HDON_1021_Fibonacci Again
AC代码:
#include <iostream> #include <cstdio> using namespace std; int main(void) { freopen("in.txt","r",stdin); long long n; while(scanf("%lld",&n)!=EOF) { n++; long long s,s1=7,s2=11; if(n==1) { s=s1; } if(n==2) { s=s2; } else { for(long long i=3;i<=n;i++) { s=(s1+s2)%3; s1=s2; s2=s; } } if(s%3==0) printf("yes\n"); else printf("no\n"); } fclose(stdin); return 0; }