/ SeriousOJ /

Record Detail

Accepted


  

Code

#include<bits/stdc++.h>
using namespace std;
const long long M=1e6+10,MOD=1000000007;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    cin>>t;
    while(t--){
       int n,k;
       cin>>n;
       vector<pair<int,int>>vec;
       for(int i=1;i<=n;i++){
         int x;
         cin>>x;
         int cnt=0;
         for(int j=1;j*j<=x;j++){
            if(x%j==0){
                cnt++;
                if(x/j!=j)cnt++;
            }
         }
         vec.push_back({cnt,x});
       }
       cin>>k;
       sort(vec.begin(),vec.end());
       int res=0;
       for(int i=0;i<n&&res==0;i++){
        int cur=vec[i].first;
        vector<int>temp;
        int l=i;
        while(l<n && vec[l].first==cur){
              temp.push_back(vec[l].second);
              l++;
        }
        i=l-1;
        sort(temp.rbegin(),temp.rend());
        for(auto it:temp){
             if(k==1){
                 res=it;
                 break;
             }
             k--;
        }
       }
       cout<<res<<"\n";
   }
       

    
    return 0;
 
}

Information

Submit By
Type
Pretest
Problem
P1008 Ordering Number
Language
C++17 (G++ 13.2.0)
Submit At
2023-11-29 16:41:38
Judged At
2024-11-11 03:50:53
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes