HDU1021 水题

来源:互联网 发布:sd卡数据恢复软件 编辑:程序博客网 时间:2024/06/14 22:48

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

判断菲波那切数列是否能被3整除。

#include<iostream>using namespace std;int a[1000005] = { 0 };int main(){        a[0] = 7; a[1] = 11;    for (int i = 2; i < 1000005; i++)        a[i] = (a[i - 1] + a[i - 2])%3;    int n;    while (cin >> n)    {        if (a[n] == 0)            cout << "yes\n";        else            cout << "no\n";    }    return 0;}

原创粉丝点击