NOIP simulation tests 22

Autistic race 

After the competition from the questions are so hard ah QAQ

The opening test did not move the keyboard within an hour. . .

Three questions are not. GG

Problem A: Number Theory

Too metaphysics

Enumeration prime factors, plus go to answer. Will not be used to add a lot of quality factor, quality factor of the big answer is not optimal.

Open two vector and shift back and forth would be finished ((

This problem also feeling completely changed nothing, why the exam is not think ah QxQ

 

 1 #include <bits/stdc++.h>
 2 
 3 typedef long long LL;
 4 int prime[63] = {0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53,
 5     59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131,
 6     137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199,
 7     211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281,
 8     283, 293};
 9 int T, K;
10 LL M;
11 std::vector<std::pair<LL, LL>> a, b;
12 
13 signed main() {
14     scanf("%d%d%lld", &T, &K, &M);
15     a.push_back(std::make_pair(1, 1));
16     for (int i = 1; i <= 62; i++) {
17         int pri = prime[i];
18         //Add a prime factor.
19         b.clear();
20         for (auto x : a) {
21             LL t = 1, cnt = 0;
22             for (; x.first <= M / t && t <= M; t *= pri, ++cnt)
23                 b.push_back(std::make_pair(x.first * t, x.second * (cnt + 1)));
24         }
25         a.clear();
26         std::sort(b.begin(), b.end());
27         std::priority_queue<LL> q;
28         //Delete the illegal numbers.
29         for (auto x : b) {
30             if (q.size() < (unsigned) K + 1) {
31                 q.push(-x.second);
32                 a.push_back(x);
33             } else {
34                 if (-q.top() == x.second) {
35                     a.push_back(x);
36                 } else if (-q.top() < x.second){
37                     q.pop();
38                     q.push(-x.second);
39                     a.push_back(x);
40                 }
41             }
42         }
43     }
44     while (T--) {
45         int n;
46         scanf("%d", &n);
47         printf("%lld\n", a[n - 1].first);
48     }
49     return 0;
50 }
Civil

Problem B: Bitwise

Gugu Gu

Problem C: Travel

Gugu Gu

Guess you like

Origin www.cnblogs.com/gekoo/p/11373560.html