天天看點

hdu_1021 fibonacci again (找規律)

http://acm.hdu.edu.cn/showproblem.php?pid=1021

分析:

      一開始暴力做的,先打了個表,但是确實WA,有些不明(如果是TLE還是可以了解的)。然後發現輸出有循環 以 ( no no yes no)循環,是以就判斷一下n就可以了。

代碼:

#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF){
        if((n%4)==2)  printf("yes\n");
        else          printf("no\n");
    }
    return 0;
}