/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 14ms 540.0 KiB

Code


#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  for (int tc = 1; tc <= tt; tc++) {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) {
      c[i] = i;
      cin >> a[i];
      for (int j = 1; j * j <= a[i]; j++) {
        if (a[i] % j == 0) {
          b[i] += 2 - (j * j == a[i]);
        }
      }
    }
    sort(c.begin(), c.end(), [&](int i, int j) {
      return b[i] ^ b[j] ? b[i] < b[j] : a[i] > a[j];
    });
    int k;
    cin >> k;
    cout << a[c[k - 1]] << '\n';
  }
  return 0;
}
 

Information

Submit By
Type
Submission
Problem
P1008 Ordering Number
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-06 20:45:45
Judged At
2024-05-06 20:45:45
Judged By
Score
100
Total Time
14ms
Peak Memory
540.0 KiB