-
Notifications
You must be signed in to change notification settings - Fork 0
/
1037_Hug_repay.cpp
80 lines (73 loc) · 1.91 KB
/
1037_Hug_repay.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
#include<stdio.h>
int main() {
int PGalleon, PSickle, PKnut;
int AGalleon, ASickle, AKunt;
int Galleon, Sickle, Kunt;
int PAllKnut, AAllKnut;
scanf("%d.%d.%d %d.%d.%d", &PGalleon, &PSickle, &PKnut, &AGalleon, &ASickle, &AKunt);
PAllKnut = PGalleon * 17 * 29 + PKnut;
AAllKnut = AGalleon * 17 * 29 + AKunt;
if (AAllKnut > PAllKnut) {
if (AKunt >= PKnut) {
Kunt = AKunt - PKnut;
}
else{
if (ASickle != 0) {
ASickle -= 1;
AKunt += 29;
Kunt = AKunt - PKnut;
}
else {
AGalleon -= 1;
ASickle += 17;
ASickle -= 1;
AKunt += 29;
Kunt = AKunt - PKnut;
}
}
if (ASickle >= PSickle) {
Sickle = ASickle - PSickle;
}
else {
AGalleon -= 1;
ASickle += 17;
Sickle = ASickle - PSickle;
}
Galleon = AGalleon - PGalleon;
printf("%d.%d.%d", Galleon, Sickle, Kunt);
}
else if (AAllKnut == PAllKnut) {
printf("0.0.0");
}
else {
printf("-");
if (PKnut >= AKunt) {
Kunt = PKnut - AKunt;
}
else {
if (PSickle != 0) {
PSickle -= 1;
PKnut += 29;
Kunt = PKnut - AKunt;
}
else {
PGalleon -= 1;
PSickle += 17;
PSickle -= 1;
PKnut += 29;
Kunt = PKnut - AKunt;
}
}
if (PSickle >= ASickle) {
Sickle = PSickle - ASickle;
}
else {
PGalleon -= 1;
PSickle += 17;
Sickle = PSickle - ASickle;
}
Galleon = PGalleon - AGalleon;
printf("%d.%d.%d", Galleon, Sickle, Kunt);
}
return 0;
}