/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 775ms 552.0 KiB

Code

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int count(int x) {
    int ret = 0;
    for (int i = 1; i <= x; i++) {
        if (x % i == 0) {
            ret++;
        }
    }
    return ret;
}

int main() {
    
    int t;

    cin >> t;

    while (t--) {

        int n, k;

        cin >> n;

        vector<pair<int, int>> nums;

        for (int i = 0; i < n; i++) {
            int x;
            cin >> x;
            nums.push_back(make_pair(x, count(x)));
        }

        sort(nums.begin(), nums.end(), [](const pair<int, int>& a, const pair<int, int>& b) -> bool {
            if (a.second == b.second) {
                return a.first > b.first;
            }
            return a.second < b.second;
        });  

        cin >> k;

        cout << nums[k - 1].first << "\n";
    }
}

Information

Submit By
Type
Submission
Problem
P1008 Ordering Number
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-07 11:14:17
Judged At
2024-11-11 02:39:00
Judged By
Score
100
Total Time
775ms
Peak Memory
552.0 KiB