-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBISHOPS.c
More file actions
34 lines (34 loc) · 677 Bytes
/
BISHOPS.c
File metadata and controls
34 lines (34 loc) · 677 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include<stdio.h>
int main()
{
long long int l,i,c,a[110];
char n[110];
for(i=0;i<110;i++)
a[i]=0;
while(scanf("%s",n)!=EOF)
{
l=strlen(n);
if(l==1 && n[0]=='1')
{printf("1\n");continue;}
long long int c=-1;
for(i=l-1;i>=0;i--)
{
a[i]=(n[i]-'0')+c;
if(a[i]<0)
c=-1,a[i]+=10;
else c=0;
}
c=0;
for(i=l-1;i>=0;i--)
{
a[i]=2*a[i]+c;
c=a[i]/10;
a[i]%=10;
}
if(c)printf("%lld",c);
for(i=0;i<l;i++)
printf("%lld",a[i]);
printf("\n");
}
return 0;
}