-
Notifications
You must be signed in to change notification settings - Fork 2
/
10174.cpp
49 lines (43 loc) · 821 Bytes
/
10174.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
#include<stdio.h>
#include<math.h>
int N,M;
void Single() {
if(N % 2)
printf("%.lf %.lf\n",ceil((double)N/2), floor((double)N/2));
else if(N % 4 == 0) {
N = N/2;
printf("%d %d\n",N/2+1,N/2-1);
}
else printf("Bachelor Number.\n");
}
void Double() {
int Tm, Teven, Tb = 0, b = 0, Tdiv4;
Tm = M-N+1;
if(Tm % 2)
b = 1;
Teven = Tm / 2;
if(N % 2 == 0)
Tb = Teven += b;
while(N % 4 ) {
N++;
if(N>M) { goto done; }
}
while(M % 4 ) {
M--;
if(M<N) { goto done; }
}
Tdiv4 = (M - N) / 4 + 1;
Tb = Teven - Tdiv4;
done:; printf("%d\n",Tb);
}
int main() {
char input[100];
int k;
while(gets(input)) {
k = sscanf(input,"%d%d",&N,&M);
if(k == 1)
Single();
else Double();
}
return 0;
}