Bzoj 2299 [HAOI2011] Vector bezout theorem
Test instructions
Give you a log of a, B, you can arbitrarily use (a, B), (A,-b), (-a,b), (-a,-b), (B,a), (b,-a), (-b,a), (-b,-a) These vectors, ask if you can spell out another vector (x, y).
Limit:
-2*1e9 <= a,b,x,y <= 2*1e9
Ideas:
The operation of the topic can be translated into:
1. x +-2a;
2. Y +-2a;
3. x +-2b;
4. Y +-2b;
5. x + a && y + b;
6. x + b && y + A;
7. x + A + b && y + a + b;
Where 5,6,7 is executed at most once.
Prove:
In the original question (x, y) If you can spell it out, it must be:
(T1*a + t2*b, T3*a + t4*b)
The parity of the T1,T2,T3,T4 determines the number of executions of the 5,6,7.
/*bzoj 2299 Test instructions: give you a logarithmic a, B, you can use arbitrarily (a, B), (A,-b), (-a,b), (-a,-b), (B,a), (b,-a), (-b,a), (-b,-a) These vectors, Ask if you can spell another vector (x, y). limitations: -2*1e9 <= a,b,x,y <= 2*1e9 idea: The operation of the topic can be translated into: 1. x +-2a; 2. Y +-2a; 3. x +-2b; 4. Y +-2b; 5. x + a && y + b; 6. x + b && y + A; 7. x + A + b && y + a + b; Where 5,6,7 is executed at most once. Proof: in the original problem (x, y) If you can spell it out, it must be: (t1*a + t2*b, T3*a + t4*b) t1,t2,t3,t4 The parity of 5,6,7 to determine the number of executions. * * #include <iostream> #include <cstdio> #include <algorithm>using namespace std; #define LL Long Longbool OK (LL x,ll y,ll D) {if (x%d==0 && y%d==0) return True;return false;} int main () {LL a,b,x,y;int t;scanf ("%d", &t), while (t--) {scanf ("%lld%lld%lld%lld", &a,&b,&x,&y); LL D=__GCD (2*A,2*B); if (ok (x,y,d) | | OK (X+A,Y+B,D) | | OK (X+B,Y+A,D) | | OK (X+A+B,Y+A+B,D)) puts ("Y"); else puts ("N");} return 0;}
Bzoj 2299 [HAOI2011] Vector bezout theorem