input | output |
---|---|
4 6 0 0 10 10 |
YES |
4 6 0 0 9 9 |
NO |
1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cmath> 5 #include <deque> 6 #include <vector> 7 #include <queue> 8 #include <iostream> 9 #include <algorithm> 10 #include <map> 11 #include <set> 12 #include <ctime> 13 using namespace std; 14 typedef long long LL; 15 typedef double DB; 16 #define For(i, s, t) for(int i = (s); i <= (t); i++) 17 #define Ford(i, s, t) for(int i = (s); i >= (t); i--) 18 #define Rep(i, t) for(int i = (0); i < (t); i++) 19 #define Repn(i, t) for(int i = ((t)-1); i >= (0); i--) 20 #define rep(i, x, t) for(int i = (x); i < (t); i++) 21 #define MIT (2147483647) 22 #define INF (1000000001) 23 #define MLL (1000000000000000001LL) 24 #define sz(x) ((int) (x).size()) 25 #define clr(x, y) memset(x, y, sizeof(x)) 26 #define puf push_front 27 #define pub push_back 28 #define pof pop_front 29 #define pob pop_back 30 #define ft first 31 #define sd second 32 #define mk make_pair 33 inline void SetIO(string Name) { 34 string Input = Name+".in", 35 Output = Name+".out"; 36 freopen(Input.c_str(), "r", stdin), 37 freopen(Output.c_str(), "w", stdout); 38 } 39 40 inline int Getint() { 41 int Ret = 0; 42 char Ch = ‘ ‘; 43 bool Flag = 0; 44 while(!(Ch >= ‘0‘ && Ch <= ‘9‘)) { 45 if(Ch == ‘-‘) Flag ^= 1; 46 Ch = getchar(); 47 } 48 while(Ch >= ‘0‘ && Ch <= ‘9‘) { 49 Ret = Ret*10+Ch-‘0‘; 50 Ch = getchar(); 51 } 52 return Flag ? -Ret : Ret; 53 } 54 55 LL p, q, a, b, c, d; 56 57 inline void Input() { 58 cin>>p>>q>>a>>b>>c>>d; 59 } 60 61 inline int Gcd(int a, int b) { 62 if(b) return Gcd(b, a%b); 63 else return a; 64 } 65 66 inline void Solve() { 67 LL x = abs(a-c), y = abs(b-d), g = Gcd(p, q); 68 if(!g || x%g || y %g) { 69 puts("NO"); 70 return; 71 } 72 x /= g, y /= g, p /= g, q /= g; 73 x &= 1, y &= 1, p &= 1, q &= 1; 74 if(!(x^y) || (p^q)) puts("YES"); 75 else puts("NO"); 76 } 77 78 int main() { 79 #ifndef ONLINE_JUDGE 80 SetIO("D"); 81 #endif 82 Input(); 83 Solve(); 84 return 0; 85 }
原文:http://www.cnblogs.com/StupidBoy/p/4912357.html