/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 22ms 568.0 KiB

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
2023-11-29 16:42:28
Judged By
Score
100
Total Time
22ms
Peak Memory
568.0 KiB