-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathacmbalaticcc_A.cpp
81 lines (71 loc) · 1.3 KB
/
acmbalaticcc_A.cpp
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include<bits/stdc++.h>
#include<math.h>
#include<conio.h>
#include<cstdio>
int main ()
{
long long int i,j,d1,d2,p,d[10005]={},D[10005]= {},R[10005]={},a,b,k,l;
scanf("%lld%lld",&a,&b);
for(i=0, l=0, p=0 ; a>0, b>0 ; i++)
{
d1=a%10;
d2=b%10;
a=a/10;
b=b/10;
if(a==0 && b==0 && (d1-d2)==0)
break;
else if(i<=10000)
d[i]=abs(d1-d2);
else if(i>10000 && l<10000)
{
l++;
D[l]=abs(d1-d2);
}
else if(l>=10000 && p<10000)
{
p++;
R[p]=abs(d1-d2);
}
}
if(p>0)
{
for(j=p; j>=0; j--)
{
if(D[j]==0)
continue;
else
break;
}
for(j=j; j>0; j--)
{
printf("%lld",D[j]);
}
}
if(l>0)
{
for(j=l; j>=0; j--)
{
if(D[j]==0)
continue;
else
break;
}
for(j=j; j>0; j--)
{
printf("%lld",D[j]);
}
}
for(j=i-1; j>=0; j--)
{
if(d[j]==0)
continue;
else
break;
}
for(j=j; j>=0; j--)
{
printf("%lld",d[j]);
}
printf("\n");
return 0;
}