/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 1ms 540.0 KiB
#4 Accepted 1ms 540.0 KiB
#5 Accepted 33ms 680.0 KiB
#6 Accepted 380ms 636.0 KiB
#7 Accepted 378ms 668.0 KiB
#8 Accepted 29ms 648.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define F                first
#define S                second
#define pb               push_back
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define P(ok)            cout << (ok ? "YES\n": "NO\n")
#define __Heart__              ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll>                   PII;
const int sz = 31700 ;
bool notPrime[sz] ;
vector< int > prime;
void seive()
{
    for(int  i = 4 ; i < sz ; i += 2) notPrime[i] = 1 ;
    int k = sqrt(sz);
    for(int i = 3 ; i < k ; i += 2)
    {
        for(int j = i*i ; j < sz ; j += i) notPrime[j] = 1 ;
    }
    prime.pb(2) ;
    for(int i = 3  ; i < sz ; i += 2) if(!notPrime[i]) prime.pb(i) ;
}
void solve()
{
   ll n ; cin >> n ; bool flag = true ;
   for(int i = 0; prime[i] <= sqrt(n) && i < prime.size(); i++){
    if(n % prime[i] == 0) {
        int Ans = n / prime[i] ;
        cout << Ans << endl ;
        flag = false ;
        break ;
    }
   }
   if(flag) cout << 1 << endl ;
}
int main()
{
     __Heart__
     seive() ;
     int t ; cin >> t ; while(t--) solve() ;
}

Information

Submit By
Type
Submission
Problem
P1052 Yet Another Array Partition
Language
C++20 (G++ 13.2.0)
Submit At
2024-04-26 00:16:58
Judged At
2024-04-29 15:10:14
Judged By
Score
100
Total Time
380ms
Peak Memory
680.0 KiB