当前位置:编程学习 > C/C++ >>

hdu1021(Fibonacci Again)

[cpp] 
#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; 

补充:软件开发 , C++ ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,