【杭电100题】【DP】2065 "红色病毒"问题

http://acm.hdu.edu.cn/showproblem.php?pid=2065
参考1:https://blog.csdn.net/funklayer/article/details/79326876
参考2:https://blog.csdn.net/wongson/article/details/4029863#commentBox

#include <iostream>

using namespace std;

int main()
{
    int t;
    __int64 n;
    int num[23];
    num[1]=2;
    for(int i=2; i<23; i++)
    {
        num[i]=(2*num[i-1])%100;
    }
    while(cin>>t&&t)
    {
        for(int i=1; i<=t; i++)
        {
            scanf("%I64d",&n);
            printf("Case %d: ",i);
            if(n==1)
                cout<<"2"<<endl;
            else if(n==2)
                cout<<"6"<<endl;
            else
                printf("%d\n",(num[(2*n-4)%20+2]+num[(n-3)%20+2])%100);
        }
        cout<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_41727666/article/details/88296265