Descriptionsios
Amugae位於一個很是大的圓形走廊中。走廊由兩個區域組成。內部區域等於nñ扇區,外部區域等於m米部門。在相同區域(內部或外部)的每對扇區之間存在壁,但在內部區域和外部區域之間沒有壁。牆壁始終存在於12點鐘位置。spa
內部區域的扇區被表示爲(1,1),(1,2),...,(1,Ñ)(1,1),(1,2),…,(1,ñ)順時針方向。外部區域的扇區被表示爲(2,1),(2,2),...,(2,米)(2,1),(2,2),…,(2,米)以相同的方式。有關清楚的理解,請參閱上面的示例圖像。.net
Amugae想知道他是否能夠從一個部門轉移到另外一個部門。他有q個問題。code
對於每一個問題,檢查他是否能夠在兩個給定的扇區之間移動。orm
Inputxml
第一行包含三個整數n,m和q(1≤n,m≤1018 ,1≤n,m≤1018,1≤q≤104,1≤q≤104) - 內部區域的扇區數,扇區數在外部區域和問題的數量。 每一個下一個q行包含四個整數sx,sy,ex,ey。 Amague想要知道是否有可能從扇區(sx,sy)(sx,sy)轉移到扇區(ex,ey)(例如,ey)。blog
Output圖片
對於每一個問題,若是Amugae能夠從(sx,sy)(sx,sy)移動到(ex,ey)(ex,ey),則打印「YES」,不然打印「NO」。 您能夠在任何狀況下(上部或下部)打印每一個字母ip
Exampleci
Input4 6 3 1 1 2 3 2 6 1 2 2 6 2 4
OutputYES NO YES
Note
示例顯示在聲明中的圖片上。
題目連接
https://vjudge.net/problem/CodeForces-1200C
AC代碼
#include <iostream> #include <cstdio> #include <fstream> #include <algorithm> #include <cmath> #include <deque> #include <vector> #include <queue> #include <string>1 #include <cstring> #include <map> #include <stack> #include <set> #include <sstream> #define IOS ios_base::sync_with_stdio(0); cin.tie(0); #define Mod 1000000007 #define eps 1e-6 #define ll long long #define INF 0x3f3f3f3f #define MEM(x,y) memset(x,y,sizeof(x)) #define Maxn 100005 using namespace std; ll n,m,q; ll sx,sy,ex,ey; int main() { cin>>n>>m>>q; ll g=__gcd(n,m); n/=g; m/=g; while(q--) { cin>>sx>>sy>>ex>>ey; sy--,ey--; ll t1,t2; if(sx==1) t1=n; if(sx==2) t1=m; if(ex==1) t2=n; if(ex==2) t2=m; if((sy/t1)==(ey/t2)) cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0; }