/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 19ms 592.0 KiB

Code

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int N = 10000 + 5;
int tc, n, m, cnt[N];

struct R {
    int x, cnt;
    bool operator<(const R &r) const {
        if (cnt == r.cnt) {
            return x > r.x;
        }
        return cnt < r.cnt;
    }
};

void calculateDivisorCount() {
    for (int i = 1; i < N; ++i) {
        for (int j = i; j < N; j += i) {
            cnt[j]++;
        }
    }
}

int main() {
    calculateDivisorCount();
    cin >> tc;
    while (tc--) {
        vector<R> vp;
        cin >> n;
        while (n--) {
            int x;
            cin >> x;
            vp.push_back({x, cnt[x]});
        }
        sort(vp.begin(), vp.end());
        int k;
        cin >> k;
        cout << vp[k - 1].x << endl;
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1008 Ordering Number
Language
C++17 (G++ 13.2.0)
Submit At
2023-12-04 16:37:56
Judged At
2024-11-11 03:49:28
Judged By
Score
100
Total Time
19ms
Peak Memory
592.0 KiB