现在的位置: 首页 > 综合 > 正文

hdu1021(Fibonacci Again)

2013年01月28日 ⁄ 综合 ⁄ 共 257字 ⁄ 字号 评论关闭
#include <iostream>
#include <cstdio>
using namespace std;
int a[1000010];
int main()
{

    a[0] = 7%3; a[1] = 11%3;
    int t;
    for(int i = 2; i < 1000000; i++){
        t = a[i-1]%3 + a[i-2]%3;
        a[i] = t%3;
    }
    int temp;
    while(scanf("%d", &temp) != EOF){
        if(!a[temp]%3) {
            printf("yes\n");
        }
        else{
            printf("no\n");
        }
    }
    return 0;
}

抱歉!评论已关闭.