Skip to content

Instantly share code, notes, and snippets.

@MagallanesFito
Last active April 15, 2020 05:30
Show Gist options
  • Save MagallanesFito/b9ad26ec837a34a47880 to your computer and use it in GitHub Desktop.
Save MagallanesFito/b9ad26ec837a34a47880 to your computer and use it in GitHub Desktop.
solucion potencias de dos omega up
#include <iostream>
using namespace std;
#define MAX_ARRAY 750
#define op_io ios_base::sync_with_stdio(0);cin.tie(0);
int res[MAX_ARRAY];
int res_size = 1;
void multiplica(){
int pot,sobrante = 0;
for(int i=0;i<res_size;i++){
pot = 2*res[i];
res[i] = (pot%10) + sobrante;
sobrante = pot/10;
}
if(sobrante > 0){
res_size++;
res[res_size-1] = sobrante;
}
}
int main(){
int n;
cin>>n;
if(n == 0){
cout << 1;
}
else{
res[res_size-1] = 2;
for(int i=2;i<=n;i++){
multiplica();
}
for(int i=res_size-1;i>=0;i--){
cout << res[i];
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment