-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1136.cpp
More file actions
34 lines (32 loc) · 856 Bytes
/
1136.cpp
File metadata and controls
34 lines (32 loc) · 856 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
#include <bits/stdc++.h>
int main() {
long n, a, b, c;
double d;
int i, t;
scanf("%d", &t);
for (i = 1; i <= t; i++) {
scanf("%ld %ld", &a, &b);
n = b - a + 1;
d = n;
c = ceil(d / 3);
c = n - c;
if (b - a == 0) {
if (a % 3 == 0 || a % 3 != 0 && (a + 1) % 3 == 0)
c = 1;
else
c = 0;
} else if (b - a == 1) {
if (a % 3 != 0 && (a + 1) % 3 == 0)
c = 2;
else
c = 1;
} else if (a % 3 != 0 && (a + 1) % 3 == 0 && b % 3 != 0 && (b + 1) % 3 == 0)
c++;
else if (a % 3 == 0 && b % 3 == 0)
c++;
else if (a % 3 != 0 && (a + 1) % 3 == 0 && b % 3 == 0)
c++;
printf("Case %d: %ld\n", i, c);
}
return 0;
}