/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 10ms 576.0 KiB

Code

#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define endl '\n'
#define Endl '\n'

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() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); // cout.tie(0);
    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:19:08
Judged At
2024-11-11 03:51:09
Judged By
Score
100
Total Time
10ms
Peak Memory
576.0 KiB