NOIP模拟测试22

自   闭   赛 

从这次比赛之后题都好难啊QAQ

开考一小时内没动键盘。。。

三道题都不会。GG

Problem A:数论

过于玄学

枚举质因子,往答案里去加。用来加入的质因子不会很多,质因子大了对答案是不优的。

开两个vector来回倒腾就完了((

这题改完感觉也没啥,为啥考场上就是想不出来啊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 }
ZIBILE

Problem B:位运算

咕咕咕

Problem C:旅行

咕咕咕

posted @ 2019-08-18 19:31  Gekoo  阅读(158)  评论(1编辑  收藏  举报