/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 548.0 KiB
#2 Accepted 1ms 764.0 KiB
#3 Accepted 1ms 756.0 KiB
#4 Accepted 1ms 764.0 KiB
#5 Accepted 537ms 764.0 KiB
#6 Time Exceeded ≥1042ms ≥708.0 KiB
#7 Time Exceeded ≥1041ms ≥620.0 KiB

Code

#include <bits/stdc++.h>
#include <iostream>
using namespace std;

typedef long long ll;
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define mp make_pair
#define pq priority_queue<int>
#define pi pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define PI acos(-1)
const int M = 1e9 + 7;
ll binExp(ll a, ll b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = res * a;
        a *= a;
        b /= 2;
    }
    return res;
}
ll gcd(ll a, ll b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b) {
    return (a / gcd(a, b)) * b;
}
void solve() {
    int n;
    cin >> n;
    if (n % 2 == 0)
        cout << n / 2 << "\n";
    else {
        vector<ll> v;
        for (int i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                v.push_back(i);
                if (i != n / i)
                    v.push_back(n / i);
            }
        }
        sort(all(v));
        cout << v[v.size() - 2] << '\n';
    }
}
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1052 Yet Another Array Partition
Contest
Brain Booster #3
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-06 15:19:07
Judged At
2024-11-11 03:34:43
Judged By
Score
40
Total Time
≥1042ms
Peak Memory
≥764.0 KiB