HDU 1021 Fibonacci Again

9 篇文章 0 订阅
/*
@author:Unibrighter
@problem:HDU 1021 Fibonacci Again
@idea:change this Fibonacci array into an array of mod 3.
@see:
fn:     7   11  18  29  47  76  ...
index:  0   1   2   3   4   5   ...
mod:    1   2   0   2   2   1   ...


*/
#include <fstream>
#include <iostream>
using namespace std;


int
main()
{
#ifndef ONLINE_JUDGE
    ifstream cin("./IN1021.TXT");
#endif


    int n=0,result=0;
    while(cin>>n)//get the input of n
    {
        int f0=7%3;
        int f1=11%3;
        //cout<<"the value of n:"<<n<<endl;


        if(n==0||n==1)
        {
            cout<<"no"<<endl;
            continue;
        }


        n--;
        while(n--)
        {


            result=(f0+f1)%3;
            f0=f1;
            f1=result;
            //cout<<"now that result :"<<result<<endl;
        }
        if(!result)cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}

无技术含量,直接水过...不过知道了hdu oj里面的GCC是gnu c compiler,而非gnu complier collection.一开始选gcc报CE...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值