Bzoj 2299 [HAOI2011] Vector bezout theorem

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.