-
Notifications
You must be signed in to change notification settings - Fork 0
/
shot.cpp
55 lines (52 loc) · 1.21 KB
/
shot.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
50
51
52
53
54
#include<iostream>
#include<queue>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<map>
#include<list>
#include<climits>
#include<set>
#include<sstream>
#include<vector>
#include<stack>
using namespace std;
vector<string> split (string s, string delimiter) {
size_t pos_start = 0, pos_end, delim_len = delimiter.length();
vector<string> res;
while ((pos_end = s.find (delimiter, pos_start)) != string::npos) {
res.push_back(s.substr (pos_start, pos_end - pos_start));
pos_start = pos_end + delim_len;
}
res.push_back (s.substr (pos_start));
return res;
}
int main(){
string s;
cin >> s;
cin >> s;
cin >> s;
auto ss = split(s, "=");
ss = split(ss[1], "..");
int xl = stoi(ss[0]), xr = stoi(ss[1]);
cin >> s;
ss = split(s, "=");
ss = split(ss[1], "..");
int yd = stoi(ss[0]), yu = stoi(ss[1]);
int cnt = 0;
for (int xv = sqrt(xl * 2) - 1; xv <= xr; ++xv) {
for (int yv = -yd; yv >= yd; --yv) {
int x = 0, y = 0, xx = xv, yy = yv;
while (x <= xr && y >= yd) {
x += xx;
if (xx > 0) --xx;
y += yy--;
if (x >= xl && x <= xr && y >= yd && y <= yu) {
++cnt;
break;
}
}
}
}
cout << cnt << endl;
}