/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 29ms 536.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) {
            x /= i;
            ret++;
            if (x != i) {
                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
2023-11-28 04:02:14
Judged At
2024-11-11 03:51:19
Judged By
Score
0
Total Time
29ms
Peak Memory
536.0 KiB