Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef unsigned long long BIGNUM;
- typedef char BOOL;
- BIGNUM gcd(BIGNUM a, BIGNUM b);
- BOOL insquare(BIGNUM xpos, BIGNUM ypos, BIGNUM x1, BIGNUM y1, BIGNUM x2, BIGNUM y2);
- int main(int argc, char **argv)
- {
- BIGNUM b_x, b_y, x1, y1, x2, y2;
- BIGNUM xstep, ystep;
- BIGNUM xpos = 0;
- BIGNUM ypos = 0;
- BIGNUM div;
- scanf("%ld%ld%ld%ld%ld%ld", &b_x, &b_y, &x1, &y1, &x2, &y2);
- div = gcd(b_x, b_y);
- xstep = b_x / div;
- ystep = b_y / div;
- while (1) {
- xpos += xstep;
- ypos += ystep;
- if (xpos >= b_x) {
- printf("Yes\n");
- break;
- }
- else if (insquare(xpos, ypos, x1, y1, x2, y2)) {
- xpos += ((x2 - x1) / div) * xstep;
- ypos += ((y2 - y1) / div) * ystep;
- continue;
- }
- else {
- printf("No\n%ld %ld\n", xpos, ypos);
- break;
- }
- }
- return 0;
- }
- BOOL insquare(BIGNUM xpos, BIGNUM ypos, BIGNUM x1, BIGNUM y1, BIGNUM x2, BIGNUM y2)
- {
- return (xpos >= x1 && xpos <= x2 &&
- ypos >= y1 && ypos <= y2);
- }
- BIGNUM gcd(BIGNUM a, BIGNUM b)
- {
- BIGNUM r = a % b;
- return (r ? gcd(b, r) : b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement