/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Accepted 98ms 1.719 MiB
#2 Accepted 98ms 1.715 MiB
#3 Accepted 98ms 1.719 MiB
#4 Accepted 101ms 1.719 MiB
#5 Runtime Error 97ms 1.723 MiB
#6 Runtime Error 97ms 1.723 MiB
#7 Runtime Error 94ms 1.723 MiB
#8 Runtime Error 98ms 1.969 MiB

Code

//Fahmidur Rahman Nafi 62 [i]
#include <bits/stdc++.h>
using namespace std;

int max_div(int num) {
    long long int highest = 1;
    for (int i = num / 2; i >= 1; i--) {
        if (num % i == 0) {
            highest = i;
            break;
        }
    }
    return highest;
}

int main(){
    const int N = 1e7+10;
    vector<bool>isPrime(N,1);
    isPrime[0] = isPrime[1] = false;          
    for (int i = 2; i < N; i++){             
        if (isPrime[i] == true){   
            for (int j = 2 * i;j < N; j+=i){
                isPrime[j] = false;             
            }
        }
    }

    long long int t;
    cin >> t;
    while (t--){
        long long int n;
        cin >> n;
        
        if (n % 2 == 0){
            cout << n/2 << endl;
        }
        else if (isPrime[n]){
            cout << 1 << endl;
        }
        else{
            long long int ans = max_div(n);
            cout << ans << endl;
        }
    }
}

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 16:34:34
Judged At
2024-10-03 13:50:00
Judged By
Score
25
Total Time
101ms
Peak Memory
1.969 MiB