題目連結:http://acm.ocrosoft.com/problem.php?cid=1172&pid=27
題目描述
任意給定一個正整數N(N≤100),計算2的n次方的值。
輸入
輸入一個正整數N。
輸出
輸出2的N次方的值。
樣例輸入
5
樣例輸出
32
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
int a[44];
while(cin>>n){
memset(a,0,sizeof(a));
a[0]=1;
while(n--)
{
for(int i=0;i<39;i++)
{
a[i]=a[i]*2;
}
for(int i=0;i<39;i++)
{
if(a[i]>=10)
{
a[i+1]+=a[i]/10;
a[i]=a[i]%10;
}
}
}
int f=0;
for(int i=39;i>=0;i--)
{
if(a[i]!=0)f=1;
if(f==1)cout<<a[i];
}
cout<<endl;
}
return 0;
}