1200C - Round Corridor - CodeForces Solution


math number theory *1400

Please click on ads to support us..

C++ Code:

#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
#include <set>
using namespace std;
long long x1, x2, r, y2;
long long s1, s2;
long long gcd(long long a, long long b)
{
	return b == 0 ? a : gcd(b, a % b);
}
long long getid(long long a, long long b)
{
	if (a == 1) return (b - 1) / s1;
	else return(b - 1) / s2;
}
int main() {
	long long n, m, q;
	cin >> n >> m >> q;
	s1 = n / gcd(max(n, m), min(n, m));
	s2 = m / gcd(max(n, m), min(n, m));
	while (q--)
	{
		cin >> x1 >> x2 >> r >> y2;
		long long id1, id2;
		id1 = getid(x1, x2);
		id2 = getid(r, y2);
		if (id1 == id2) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


Comments

Submit
0 Comments
More Questions

762C - Two strings
802M - April Fools' Problem (easy)
577B - Modulo Sum
1555B - Two Tables
1686A - Everything Everywhere All But One
1469B - Red and Blue
1257B - Magic Stick
18C - Stripe
1203B - Equal Rectangles
1536A - Omkar and Bad Story
1509A - Average Height
1506C - Double-ended Strings
340A - The Wall
377A - Maze
500A - New Year Transportation
908D - New Year and Arbitrary Arrangement
199A - Hexadecimal's theorem
519C - A and B and Team Training
631A - Interview
961B - Lecture Sleep
522A - Reposts
1166D - Cute Sequences
1176A - Divide it
1527A - And Then There Were K
1618E - Singers' Tour
1560B - Who's Opposite
182B - Vasya's Calendar
934A - A Compatible Pair
1618F - Reverse
1684C - Column Swapping