hdu 2065 "红色病毒"问题(指数母函数)

#include <stdio.h>

 

typedef long long LL;

#define MOD 100

LL pow2(LL a, LL n, int mod = MOD) //2^n % mod
{
    LL s = 1;
    while(n)
    {
        if(n & 1) s = (s * a) % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return s % MOD;
}

int main()
{
 //   freopen("indata.txt", "r", stdin);
    int T;
    while(scanf("%d", &T), T)
    {
        int cas = 1;
        while(T--)
        {
            LL n;
            scanf("%I64d", &n);
            printf("Case %d: %I64d\n", cas++, (pow2(2, n - 1) + pow2(4, n - 1)) % MOD);
        }
        printf("\n");
    }
    return 0;
}

posted @ 2010-10-22 01:31  菜到不得鸟  阅读(261)  评论(0)    收藏  举报