The 2019 Asia Nanchang First Round Online Programming Contest

E. Magic Master

When the game get a list with xy, deque found after the game faster, probably because deque memory continuously. In short deque is an efficient data structure, or even delete random access random, block array automatically managed? Manual maintenance information is not only trouble spots on the block.

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

deque<int> dq;

int main() {
    int T;
    scanf("%d", &T);
    for(int ti = 1; ti <= T; ++ti) {
        int n, m;
        scanf("%d%d", &n, &m);
        dq.push_back(n);
        for(int i = n - 1; i >= 1; --i) {
            for(int mi = 1; mi <= m; ++mi) {
                dq.push_back(dq.front());
                dq.pop_front();
            }
            dq.push_back(i);
        }

        int Q;
        scanf("%d", &Q);
        for(int qi = 1, q; qi <= Q; ++qi) {
            scanf("%d", &q);
            printf("%d\n", dq[n - q]);
        }
        dq.clear();
    }
    return 0;
}

B. Fire-Fighting Hero

Misunderstood the meaning of the questions, the topic a little side thing. All of the fire brigade in the new context of meaning of the questions is the same single source departure, only to find a super source connected to a right side to zero.

A. Enju With math problem

The first 200 prime numbers to prevent violence before the sentence behind the small things.

Appears to be first pulled out a few of the few prime 1.5e8 detected around a bit they are not there, the complexity of the flower is not high. Then all these prime numbers multiplied by 2 to get some composite number 2p, then (2 except than 2 = 4) nature of the product according to the Euler function, their functions must be Euler Phi (2P) = Phi (2) Phi ( p), according to which the number of the engagement position to find again.

C. Hello 2019

This looks like the morning wrong that question.

Guess you like

Origin www.cnblogs.com/Inko/p/11489007.html