-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuku.cpp
More file actions
58 lines (54 loc) · 1.15 KB
/
buku.cpp
File metadata and controls
58 lines (54 loc) · 1.15 KB
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
#include<stdio.h>
int main()
{
int t;
scanf("%d", &t);
for(int i = 0; i < t; i++){
long long int n, x;
scanf("%lld %lld", &n, &x);
long int counter = 0;
long int counter2 = 0;
printf("Case #%d: ", i+1);
// GENAP (BERES)
if(n % 2 == 0){
if(x == 1 || x == n){
printf("0\n");
} else{
for(long long int j = 1; j <= (x/2); j++){
counter++;
}
// printf("Counter 1: %d\n", counter);
for(long long int j = 0; j <= (n-x-1)/2; j++){
counter2++;
}
// printf("Counter 2: %d\n", counter2);
if(counter < counter2){
printf("%lld\n", counter);
} else{
printf("%lld\n", counter2);
}
}
}
// GANJIL
else{
if(x == 1 || x == n || x == n-1){
printf("0\n");
} else{
for(long long int j = 1; j <= (x/2); j++){
counter++;
}
// printf("Counter 1: %d\n", counter);
for(long long int j = 0; j <= (n-x-2)/2; j++){
counter2++;
}
// printf("Counter 2: %d\n", counter2);
if(counter < counter2){
printf("%lld\n", counter);
} else{
printf("%lld\n", counter2);
}
}
}
}
return 0;
}