/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 888.0 KiB
#2 Accepted 2ms 1012.0 KiB
#3 Accepted 2ms 1.02 MiB
#4 Accepted 2ms 1.02 MiB
#5 Runtime Error 2ms 1.074 MiB
#6 Runtime Error 2ms 1.02 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#define int long long
int prime[50000],nprime=1;
int mark[50000],pal[50005];
vector<int>primes;
void sieve(int n){
    int i,j,limit=sqrt(n*1)+2;
    mark[1]=1;
    for(i=4;i<=n;i+=2)mark[i]=1;
    prime[2]=nprime;
    nprime++;
    primes.push_back(2);
    for(i=3;i<=n;i+=2){
            if(!mark[i]){
                    primes.push_back(i);
                    prime[i]=nprime;
                    nprime++;
                    if(i<=limit){
                            for(j=i*i;j<=n;j+=i*2){
                                    mark[j]=1;
                            }
                    }
            }
    }
}

int32_t main () {
  cin.tie(0)->sync_with_stdio(0);
  int t = 1;
  cin >> t;
  sieve(3e4);
  while (t--) {
      int n, x, ans = INT_MAX;
      cin >> n;
      if (n%2) {
          ans = n;
          for (int i = 0; primes[i]*primes[i] <= n; i++) {
              if (n%primes[i] == 0) {
                  ans = min (ans, primes[i]);
              }
          }
          ans = n/ans;
      }
      else ans = n/2;
      cout << ans << "\n";
  }
}

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:32:11
Judged At
2024-11-11 03:34:08
Judged By
Score
25
Total Time
2ms
Peak Memory
1.074 MiB