#include<stdio.h>
#include<string.h>
int main(){
int t,a,b,c,d,ar[110],i,j,k,l,h;
char br[110];
while(scanf("%s",br)!=EOF){
j=0;
if(strlen(br)==1 && br[0]==49)
printf("1\n");
else{
for(i=strlen(br)-1;i>=0;i--){
ar[j]=br[i]-'0';
j++;
}
a=0;
for(i=0;i<j;i++){
b=ar[i]*2+a;
ar[i]=b%10;
a=b/10;
}
if(a>0){
ar[i]=a;
k=i;
}else
k=i-1;
c=2;
for(h=0;h<=k;h++){
if(ar[h]>=c){
ar[h]=ar[h]-c;
break;
}else{
ar[h]=10+ar[h]-c;
c=1;
}
}
if(ar[k]>0)
printf("%d",ar[k]);
for(l=k-1;l>=0;l--){
printf("%d",ar[l]);
}
printf("\n");
}
}
return 0;
}
#include<string.h>
int main(){
int t,a,b,c,d,ar[110],i,j,k,l,h;
char br[110];
while(scanf("%s",br)!=EOF){
j=0;
if(strlen(br)==1 && br[0]==49)
printf("1\n");
else{
for(i=strlen(br)-1;i>=0;i--){
ar[j]=br[i]-'0';
j++;
}
a=0;
for(i=0;i<j;i++){
b=ar[i]*2+a;
ar[i]=b%10;
a=b/10;
}
if(a>0){
ar[i]=a;
k=i;
}else
k=i-1;
c=2;
for(h=0;h<=k;h++){
if(ar[h]>=c){
ar[h]=ar[h]-c;
break;
}else{
ar[h]=10+ar[h]-c;
c=1;
}
}
if(ar[k]>0)
printf("%d",ar[k]);
for(l=k-1;l>=0;l--){
printf("%d",ar[l]);
}
printf("\n");
}
}
return 0;
}
#include
ReplyDelete#include
using namespace std;
int main()
{
char n[109];
while(cin>>n)
{
int ans;
int k;
k=0;
while(n[k]!='\0')
{
k++;
}
if(n[k-1]=='1'&& k==1)
{
cout<<1;
}
// else if(n[k-1]==)
else
{
int l,i;
l=strlen(n);
int a[109];
for(i=0;i=0;i--)
{
if(a[i]==0 && p==0)
{
a[i]=9;
}
if(p==0)
{
a[i]=a[i]-1;
p=1;
}
}
int c,d;
c=0;
for(i=l-1;i>=0;i--)
{
if(i==0)
{
a[i]=a[i]*2+c;
}
else
{
d=a[i]*2+c;
a[i]=d%10;
d=d/10;
c=d%10;
}
}
if(p!=0)
{
for(i=0;i<l;i++)
{
cout<<a[i];
}
cout<<endl;
}
else cout<<0;
}
}
return 0;
}
//what is the error in this solution ....please main me at drunken11master@gmail.com