/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 796.0 KiB
#2 Accepted 3ms 464.0 KiB
#3 Accepted 3ms 408.0 KiB
#4 Accepted 3ms 588.0 KiB
#5 Accepted 11ms 636.0 KiB
#6 Accepted 97ms 608.0 KiB
#7 Accepted 97ms 640.0 KiB
#8 Accepted 16ms 640.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
const long long M=2e5+1,MOD=1000000007;
typedef long long ll;
vector<int>prime;
void precalculate_prime(){
    prime.push_back(2);
    for(ll i=3;i*i<=1e9;i+=2){
        int x=1;
        for(auto it:prime){
            if(it*it>i)break;
            if(i%it==0){
                x=0;
                break;
            }
        }
        if(x)prime.push_back(i);
    }
    
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    precalculate_prime();
    int t=1;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int res=1;
        for(auto it:prime){
            if(n%it==0){
                res=n/it;
                break;
            }
        }
        cout<<res<<"\n";

    }




    
   
   return 0;
 
}

Information

Submit By
Type
Submission
Problem
P1052 Yet Another Array Partition
Language
C++20 (G++ 13.2.0)
Submit At
2024-04-23 16:03:28
Judged At
2024-04-29 15:10:10
Judged By
Score
100
Total Time
97ms
Peak Memory
796.0 KiB