/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 752.0 KiB
#2 Accepted 3ms 888.0 KiB
#3 Accepted 3ms 836.0 KiB
#4 Accepted 3ms 868.0 KiB
#5 Accepted 32ms 980.0 KiB
#6 Accepted 536ms 832.0 KiB
#7 Accepted 108ms 1012.0 KiB
#8 Accepted 65ms 1000.0 KiB

Code

#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define endl '\n'
#define Endl '\n'

using namespace std;

const int N = 2e5 + 5;
int tc, n, m, a[N];

// sieve
bool is_prime[N];
vector<int> primes;

void sieve() {
    fill(is_prime, is_prime + N, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i < N; i++) {
        if (is_prime[i]) {
            primes.push_back(i);
            for (int j = i + i; j < N; j += i) {
                is_prime[j] = false;
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); // cout.tie(0);
    sieve();
    cin >> tc;
    while (tc--) {
        cin >> n;
        int Ans = 1;
        for (auto x : primes) {
            if (x > n) {
                break;
            }
            if (n % x == 0) {
                Ans = n / x;
                break;
            }
        }
        cout << Ans << endl;
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1052 Yet Another Array Partition
Contest
Brain Booster #3
Language
C++17 (G++ 13.2.0)
Submit At
2024-05-06 16:42:32
Judged At
2024-11-11 03:32:52
Judged By
Score
100
Total Time
536ms
Peak Memory
1012.0 KiB