Innovation lab of Hunan University of Technology 2015 freshman competition (1) 1002 (reopened), Hunan 1002
Time Limit: 3000/1000 ms (Java/Other) Memory Limit: 65535/32768 K (Java/Other) Total Submission (s): 39 Accepted Submission (s ): 23 Font: Times New Roman | Verdana | GeorgiaFont Size: Photo → Problem Description: The first handsome man of the art, the moon god, returned from Alibaba, ACM friends are naturally very happy!
Of course, they are so happy that they want to beat the moon in addition to the moon god.
After all, the moon god is rich and rich. In addition to treating guests, he will also answer questions from his friends.
However, as a result, the moon is overwhelmed by the sea, so he wants you to help and answer these questions on his behalf.
For each integer q, it indicates the problem. The integer p indicates the = q ^ p output. Input Multiple groups of Input, each group of Input two integers q and p (1 <= q <= 10, 1 <= p <= 9) Output for each group of data first Input a case #: # indicates the group of data
Then an integer a is output, indicating the result Sample Input.
1 12 23 3
Sample Output
case 1:1case 2:4case 3:27
Authorikids has nothing to say, that is, a = q ^ p. It is really afraid that timeout can be used as a quick 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 is equivalent to (n % 2) = 1 pw * = x; x * = x; n >>=1; // n >>=1 is 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 ;}