-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathdiehard.cpp
More file actions
50 lines (42 loc) · 901 Bytes
/
diehard.cpp
File metadata and controls
50 lines (42 loc) · 901 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define inf 1000000000
#define MAXN 100000
using namespace std;
int main() {
int t;
scanf("%d", &t);
int h, a;
for (int qwertz = 0; qwertz < t; ++qwertz) {
scanf("%d%d", &h, &a);
int sol = 1;
while (h > 0 && a > 0) {
while (a <= 8 && h > 17) {
sol += 2;
h -= 17;
a += 7;
}
int mini = min((h-1)/2, (a-1)/8);
if (!mini) break;
sol += mini*2;
h -= mini*2;
a -= mini*8;
}
printf("%d\n", sol);
}
return 0;
}