Submission #36995818


Source Code Expand

#include<bits/stdc++.h>

typedef long long ll;

using namespace std;

void setIO(){
    ios::sync_with_stdio(0);
    cin.tie(0);
}

bool isPrime(ll n){
    if(n==1)return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}

long long getMaxPrimefactor(long long n) {
   long long maxPF = -1;
   while (n % 2 == 0) {
      maxPF = 2;
      n /= 2;
   }
   for (int i = 3; i <= sqrt(n); i += 2) {
      while (n % i == 0) {
         maxPF = i;
         n = n / i;
      }
   }
   if (n > 2)
   maxPF = n;
   return maxPF;
}

int main(){

    setIO();

    ll n;
    cin>>n;
    if(isPrime(n)) cout<<n<<"\n";
    else if(floor(sqrt(n))==ceil(sqrt(n)) && isPrime(floor(sqrt(n))))cout<<n<<"\n";
    else{
        // for(ll i=n/2;i>=2;i--){
        //     if(n%i==0 && isPrime(i)){
        //         cout<<i<<"\n";
        //         break;
        //     }
        // }
        cout<<getMaxPrimefactor(n)<<"\n";
        
    }
    return 0;
}

Submission Info

Submission Time
Task D - Factorial and Multiple
User Sayantan108
Language C++ (GCC 9.2.1)
Score 0
Code Size 1033 Byte
Status WA
Exec Time 21 ms
Memory 3636 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 29
WA × 34
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, hand_15.txt, hand_16.txt, hand_17.txt, hand_18.txt, hand_19.txt, hand_20.txt, hand_21.txt, hand_22.txt, hand_23.txt, hand_24.txt, hand_25.txt, hand_26.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt
Case Name Status Exec Time Memory
example_00.txt AC 8 ms 3488 KiB
example_01.txt AC 7 ms 3544 KiB
example_02.txt AC 2 ms 3572 KiB
hand_00.txt WA 2 ms 3484 KiB
hand_01.txt AC 2 ms 3492 KiB
hand_02.txt AC 19 ms 3524 KiB
hand_03.txt AC 13 ms 3420 KiB
hand_04.txt AC 15 ms 3516 KiB
hand_05.txt WA 16 ms 3476 KiB
hand_06.txt WA 13 ms 3472 KiB
hand_07.txt AC 21 ms 3484 KiB
hand_08.txt AC 18 ms 3528 KiB
hand_09.txt AC 7 ms 3408 KiB
hand_10.txt AC 5 ms 3420 KiB
hand_11.txt WA 2 ms 3472 KiB
hand_12.txt AC 11 ms 3476 KiB
hand_13.txt WA 11 ms 3412 KiB
hand_14.txt AC 5 ms 3412 KiB
hand_15.txt AC 5 ms 3416 KiB
hand_16.txt WA 6 ms 3472 KiB
hand_17.txt WA 3 ms 3636 KiB
hand_18.txt WA 2 ms 3476 KiB
hand_19.txt WA 2 ms 3420 KiB
hand_20.txt WA 2 ms 3416 KiB
hand_21.txt WA 2 ms 3588 KiB
hand_22.txt WA 2 ms 3568 KiB
hand_23.txt WA 3 ms 3636 KiB
hand_24.txt WA 2 ms 3512 KiB
hand_25.txt WA 2 ms 3356 KiB
hand_26.txt AC 3 ms 3416 KiB
random_00.txt WA 2 ms 3420 KiB
random_01.txt WA 2 ms 3512 KiB
random_02.txt WA 3 ms 3540 KiB
random_03.txt WA 2 ms 3412 KiB
random_04.txt WA 2 ms 3420 KiB
random_05.txt WA 2 ms 3476 KiB
random_06.txt WA 2 ms 3468 KiB
random_07.txt WA 2 ms 3472 KiB
random_08.txt WA 2 ms 3420 KiB
random_09.txt WA 2 ms 3528 KiB
random_10.txt WA 2 ms 3528 KiB
random_11.txt WA 2 ms 3420 KiB
random_12.txt WA 2 ms 3536 KiB
random_13.txt WA 2 ms 3516 KiB
random_14.txt AC 2 ms 3516 KiB
random_15.txt WA 2 ms 3484 KiB
random_16.txt WA 2 ms 3480 KiB
random_17.txt AC 2 ms 3480 KiB
random_18.txt WA 2 ms 3548 KiB
random_19.txt WA 2 ms 3420 KiB
random_20.txt AC 1 ms 3416 KiB
random_21.txt WA 3 ms 3536 KiB
random_22.txt AC 2 ms 3460 KiB
random_23.txt AC 2 ms 3460 KiB
random_24.txt AC 6 ms 3420 KiB
random_25.txt AC 2 ms 3460 KiB
random_26.txt AC 2 ms 3356 KiB
random_27.txt AC 2 ms 3480 KiB
random_28.txt AC 2 ms 3524 KiB
random_29.txt AC 2 ms 3412 KiB
random_30.txt AC 3 ms 3416 KiB
random_31.txt AC 3 ms 3596 KiB
random_32.txt AC 2 ms 3488 KiB