Skip to content

Instantly share code, notes, and snippets.

@secretjunio
Last active March 12, 2019 03:45
Show Gist options
  • Save secretjunio/f222bc3e62904c8546aba4dbe5d778bb to your computer and use it in GitHub Desktop.
Save secretjunio/f222bc3e62904c8546aba4dbe5d778bb to your computer and use it in GitHub Desktop.
#include<iostream>
using namespace std;
int kt(int k)
{
if(k/10==1)
return 1;
else
return 0;
}
int main()
{
int a[100000],n,m;
cout<<"nhap so mu:";
cin>>n;
a[0]=1;
for(int i=1;i<=n;i++)//lap lai n lan
{
for(int j=0;j<i;j++)
{
a[j]*=2;
}
for(int j=0;j<i;j++)
{
if(kt(a[j])==1)
{
a[j]%=10;
a[j+1]++;
}
}
}
for(int i=n-1;i>=0;i--)
{
m=n-i;
m=n-m;
if(a[i]!=0)
break;
}
cout<<m<<endl;
cout<<"ket qua\n";
for(int i=m;i>=0;i--)
{
cout<<a[i];
}
return 0;
system("pause");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment