Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- struct Point {
- int x;
- int y;
- auto operator<=>(const Point &) const = default;
- auto operator+(const Point &b) const {
- return Point{.x = x + b.x, .y = y + b.y};
- }
- void operator+=(const Point &b) {
- x += b.x;
- y += b.y;
- }
- };
- int main() {
- auto start = absl::Now();
- int x0 = 94;
- int x1 = 151;
- int y0 =-156;
- int y1 =-103;
- auto isOk = [&](const Point& p){
- return p.x >= x0 && p.x <=x1 && p.y >= y0 && p.y <= y1;
- };
- int ans = 0;
- for (int vx = 1; vx<=x1; ++vx) {
- for(int vy = y0; vy <= abs(y0); ++vy) {
- Point v = {.x = vx, .y = vy};
- Point p = {.x = 0, .y = 0};
- while(p.x <= x1 && p.y >= y0) {
- p += v;
- v.y -=1;
- if (v.x >0) v.x--;
- if (isOk(p)) {
- ans++;
- break;
- }
- }
- }
- }
- cout << ans << endl;
- cout << absl::Now() - start << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment