Codeforces Round #280 (Div. 2)

Source: Internet
Author: User

This problem is simply astonishing.


ABC is almost always a sign-in question.


D words

Convert two people's firing time into an integer

Ask for a gcd, except for a moment.

Let's say the firing frequency of the two is 1 seconds x,1 second Y.

X, y gcd is G

Conversion is equivalent to

The first person y/g second shot, the second person x/g second shot a

Then two people will shoot at the same time in x/g*y/g seconds.

So every x/g*y/g second is a cycle.

Assuming the monster's blood has a, then a% (X+y) is the last cycle to shoot the amount of blood

At this time I have been too lazy to continue to think, go straight to the number of people shooting, OK


#include <iostream> #include <cstdio> #include <cstring> #include <queue> #include <cmath > #include <algorithm> #include <map> #define MAXN 55555#define maxm 222222#define INF 1000000001using    Namespace Std;int n, x, Y, a;int main () {scanf ("%d%d%d", &n, &x, &y);    int g = __GCD (x, y);    x/= g;    Y/= G;        for (int i = 0; i < n; i++) {scanf ("%d", &a);        A%= (x + y); if (a = = 0 | |        (A + 1)% (x + y) = = 0) puts ("Both");            else {int flag = 0;            int low = 1, high = x;                while (low <= high) {int mid = (low + high) >> 1;                Long Long TMP = (long Long) mid * (long long) y;                Long Long z = tmp/(long long) x;                if (z + mid > a) {high = mid-1;                    } else if (z + mid = = a) {flag = 1;                Break      } else {low = mid + 1;          }} if (flag) {puts ("Vanya");            } else {puts ("Vova"); }}} return 0;}



E words

The topic gives a very good limit.

is from the x direction or the y direction, you start from 0, walk a n step, must be able to traverse all the 0~n-1

And then X-direction you go from 0 simulation to an n-step, get an x-coordinate sequence

Y coordinates are doing the same thing.

Two sequences. can be recycled.

Then you choose to go from one point (x0,y0)

Is nothing more than the two sequence, the x sequence starts from the x0, the y sequence starts from the y0, each walks a n step, to see what the point is meets the question request

Once again, it was found that the relative position of the two sequences was seen.

For all given points, the relative positions of the corresponding two sequences are calculated, and the last statistic can be


#include <iostream> #include <cstdio> #include <cstring> #include <queue> #include <cmath > #include <algorithm> #include <map> #define MAXN 55555#define maxm 222222#define INF 1000000001using    Namespace Std;int posx[1111111], Posy[1111111];int N, M, DX, Dy;int x[111111], y[111111];int num[1111111];int main () {    scanf ("%d%d%d%d", &n, &m, &AMP;DX, &dy);    int now = 0;    int ind = 0;        while (posx[now] = = 0) {Posx[now] = ++ind;    Now = (now + dx)% n;    } now = 0, ind = 0;        while (posy[now] = = 0) {Posy[now] = ++ind;    Now = (now + dy)% n;    } int mx = 0, p = 0;        for (int i = 0; i < m; i++) {scanf ("%d%d", &x[i], &y[i]);        int px = posx[x[i]];        int py = posy[y[i]];        int t = (py-px + N)% n;        num[t]++;            if (Num[t] > mx) {mx = num[t];        p = t;        }} for (int i = 0; i < m; i++) {int px = posx[x[i]]; int py =Posy[y[i]];        int t = (py-px + N)% n;            if (t = = p) {printf ("%d%d\n", X[i], y[i]);        Break }} return 0;}



Codeforces Round #280 (Div. 2)

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.