CSP-SJ Bioinformatics Download
time limit: 1000 ms memory limit: 65536 KB
4943: submitted Number: Number 9709 by
[Title] Description
values for any given a positive integer N (N≤100), calculates the n-th power of 2 .
[INPUT]
enter a positive integer N.
[Output]
output value of the N-th power of 2.
[Input] Sample
5
[output] Sample
32
[Source]
No
代码如下:
#include<iostream>
#include<cstring>
#define N 50
using namespace std;
int a[N],n,lena=1;
int main(){
cin>>n;
a[0]=1;
while(n--){
for(int i=0;i<lena;i++)a[i]*=2;
for(int i=0;i<lena;i++){
if(a[i]>9){
a[i+1]++;
a[i]-=10;
if(i==lena-1)lena++;
}
}
}
for(int i=lena-1;i>=0;i--)cout<<a[i];
cout<<endl;
}