/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 532.0 KiB

Code

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

int count(int x) {
    int ret = 0;
    for (int i = 1; i * 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
Pretest
Problem
P1008 Ordering Number
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-07 11:14:05
Judged At
2024-11-11 02:39:01
Judged By
Score
0
Total Time
1ms
Peak Memory
532.0 KiB