The return story of the first handsome in the big work Time limit:3000/1000ms (Java/other) Memory limit:65535/32768k (Java/other) total submission (s): All ACC epted Submission (s): 23font:times New Roman | Verdana | Georgiafont Size:←→problem Description The first handsome man month God from Ali back, ACM's small partners are naturally very happy!
Of course, they are so happy, except for the moon God, but also want to kill the moon God a meal.
Moon God, after all, is the moon god, deep pockets, in addition to the guests, he will answer the questions of the small partners.
But, as the problem comes, it's like overwhelming the moon, so he wants you to help him answer these questions on his behalf.
For each integer q, which represents the problem, the integer p, which represents the snapped you want to output is a = Q^p. Input multiple inputs, each set input two integers q and p (1<=q<=10,1<=p<=9) output First Enter a case # for each set of data #: #代表第几组数据
Then output an integer a that represents the result of the sample Input
1 12 23 3
Sample Output
Case 1:1case 2:4case 3:27
Authorikids There is nothing to say, is a = Q^p, is afraid to timeout can be used fast power
#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 longusing namespace Std;int pow (int x, int n) { int pw = 1; while (n > 0) { if (N & 1) //N & 1 equivalent to (n% 2) = = 1 pw *= x; x *= x; n >>= 1; N >>= 1 equivalent to 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;}
Hunan University of Technology Innovation Laboratory 2015 Freshman (i) 1002 (re-opened)