-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnew.cpp
More file actions
36 lines (29 loc) · 652 Bytes
/
Copy pathnew.cpp
File metadata and controls
36 lines (29 loc) · 652 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
35
36
#include<stdio.h>
#define MAXN 1080
int Close(int a, int b) {
int c = 0;
while(a != b) {
c++;
a--;
if(a == -1) a = 39;
}
return c * 9;
}
int Counter(int a, int b) {
int c = 0;
while(a != b) {
c++;
a++;
if(a == 40) a = 0;
}
return c * 9;
}
int main() {
int a, b, c, d;
while(scanf("%d%d%d%d",&a,&b,&c,&d) == 4) {
if(a==0 && b== 0 && c==0 && d== 0)
break;
printf("%d\n",Close(a, b)+ Counter(b, c) + Close(c,d) + MAXN);
}
return 0;
}