/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 30ms 572.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
Submission
Problem
P1008 Ordering Number
Contest
Beta Round #1
Language
C++17 (G++ 13.2.0)
Submit At
2023-11-29 16:33:08
Judged At
2024-11-11 03:50:56
Judged By
Score
100
Total Time
30ms
Peak Memory
572.0 KiB