真的没骗你,这道才是简单题 —— 对任意给定的不超过 10 的正整数 n,要求你输出 2n。不难吧?
输入格式:
输入在一行中给出一个不超过 10 的正整数 n。
输出格式:
在一行中按照格式 2^n = 计算结果
输出 2n 的值。
输入样例:
5
输出样例:
2^5 = 32
代码长度限制:16 KB
时间限制:400 ms
内存限制:64 MB
题解代码:
#include <iostream>
#include <cstdio>
using namespace std;
int n;
int res = 1;
int main(){
cin >> n;
int i = n;
while(n--){
res *= 2;
}
printf ("2^%d = %d", i, res);
return 0;
}