CF1200C
Meaning of the questions:
Q are divided into inner and outer circle n, parts of m, each numeral has asked if can go from one part to another, there must be a 12 o'clock line.
solution:
If there is a through-wall 1 and 2, so that the sides will not communicate. Then at n or m / common denominator of such walls will clearly appear.
CODE:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define LL long long
LL n,m,q;
inline LL gcd(LL a,LL b) {
return !b ? a : gcd(b,a%b);
}
int main() {
scanf("%lld%lld%lld",&n,&m,&q);
LL G = gcd(n, m);
LL nn = n / G, mm = m / G;
while (q--) {
LL x1, y1, x2, y2;
scanf("%lld%lld%lld%lld",&x1,&y1,&x2,&y2);
y1--, y2--;
LL ans1, ans2;
if(x1 == 1) ans1 = y1 / nn;
else ans1 = y1 / mm;
if(x2 == 1) ans2 = y2 / nn;
else ans2 = y2 / mm;
if(ans1 == ans2) puts("YES");
else puts("NO");
}
//system("pause");
return 0;
}