n=1  --> ans = 2 = 1*2 = 2^0(2^0+1)

n=2  -->  ans = 6 = 2*3 = 2^1(2^1+1)

n=3  -->  ans = 20 = 4*5 = 2^2(2^2+1)

n=4  -->  ans = 72 = 8*9 = 2^3(2^3+1)

n=k  -->  ??? = 2^k-1*(2^k-1+1)
于是题目转化为快速幂求模问题.....
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int solve(ll a, ll b) {
    ll ans = 1;
    a %= 100;
    while(b) {
        if(b&1) ans = ans *a % 100;
        b /= 2;
        a = a * a % 100;
    }
    return ans;
}
int main() {
    int t;
    while(cin >> t && t) {
        for(int i = 1; i <= t; i++) {
            ll n;
            cin >> n;
            n = solve(2, n-1);
            printf("Case %d: %d\n", i, (n*(n+1))%100);
        }
        printf("\n");
    }
    return 0;
}

 

posted on 2018-06-15 23:56  kindleheart  阅读(144)  评论(0编辑  收藏  举报