Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <algorithm>
- #include <cmath>
- using namespace std;
- int n;
- double x, y, w, h, r;
- double dx, dy, t;
- long long div(double a, double b)
- {
- return (floor)(a / b);
- }
- double mod(double a, double b)
- {
- return a - div(a, b) * b;
- }
- int main()
- {
- /*
- freopen("in", "r", stdin);
- freopen("out", "w", stdout);
- //*/
- scanf("%lf %lf %lf %d %lf %lf", &w, &h, &r, &n, &x, &y);
- w -= 2 * r;
- h -= 2 * r;
- x -= r;
- y -= r;
- for (int i = 0; i < n; i++)
- {
- scanf("%lf %lf %lf", &dx, &dy, &t);
- dx *= t;
- dy *= t;
- double
- X = x + dx,
- Y = y + dy;
- long long
- xans = div(max(x, X), w) - div(min(x, X), w),
- yans = div(max(y, Y), h) - div(min(y, Y), h);
- printf("%lld\n", xans + yans);
- x = mod(X, w);
- y = mod(Y, h);
- if (xans & 1) x = w - x;
- if (yans & 1) y = h - y;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement