/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 18ms 540.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
Contest
Beta Round #1
Language
C++17 (G++ 13.2.0)
Submit At
2023-11-29 16:20:21
Judged At
2024-11-11 03:51:09
Judged By
Score
100
Total Time
18ms
Peak Memory
540.0 KiB