1 1 2 2 3 3
case 1:1 case 2:4 case 3:27
#include<stdio.h> //#include<bits/stdc++.h> #include<string.h> #include<iostream> #include<math.h> #include<sstream> #include<set> #include<queue> #include<vector> #include<algorithm> #include<limits.h> #define inf 0x3fffffff #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 #define LL long long using namespace std; int pow(int x, int n) { int pw = 1; while (n > 0) { if (n & 1) // n & 1 等價於 (n % 2) == 1 pw *= x; x *= x; n >>= 1; // n >>= 1 等價於 n /= 2 } return pw; } int main() { int p,q; int num=1; while(cin>>p>>q) { printf("case %d:%d\n",num++,pow(p,q)); } return 0; }