Submission #40774699


Source Code Expand

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

typedef long long int ll;
#define IOS ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef tree<int,null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update>order_set;
typedef pair<int,int>pr;
#define all(i)     i.begin() , i.end()
#define ft     first
#define sn     second
#define pb push_back

#define en "\n"
#define dbg cout<<"rony\n";

#define MAXN 1000010
#define inf 1e6
const ll mod = 1e9+7;

ll k;
vector<pair<ll,ll>>v;

void primeFactor()
{
    ll n = k;
    for(ll i = 2;i*i <= k;i++)
    {
        if(n%i == 0){
            int cn = 0;
            while(n%i == 0){
                n /= i;
                cn++;
            }
            v.pb({i,cn});
        }
    }
    if(n != 1) v.pb({n,1});
}

bool chk(ll md,ll x,ll cn)
{
  ll rs = 0;
  while(md)
  {
    md = md / x;
    rs += md;
  }
  if(rs >= cn) return true;
  return false;
}
void solve()
{
  cin >> k;

  primeFactor();
  ll ans = 0;
  for(int i = 0;i < v.size();i++)
  {
     ll x = v[i].ft; ll cn = v[i].sn;
     ll an;

     ll l = 1, r = 1e12;
     while(l <= r)
     {
       ll md = l + (r - l)/2;
       bool ok = chk(md,x,cn);
       if(ok){
        an = md;
        r = md - 1;
       }
       else l = md + 1;
     }
     ans = max(an,ans);
  }

  cout<<ans<<en;

}
int main()
{
    IOS;
   int t;
   t = 1;
  
   // cin >> t;

   int c = 0;
    while ( t-- )
    {
        // cout<<"Case "<<++c<<": ";
        solve();
    }
    return 0;
}   

Submission Info

Submission Time
Task D - Factorial and Multiple
User ar_rony1
Language C++ (GCC 9.2.1)
Score 400
Code Size 1705 Byte
Status AC
Exec Time 21 ms
Memory 3612 KiB

Compile Error

./Main.cpp: In function ‘void solve()’:
./Main.cpp:63:19: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::pair<long long int, long long int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   63 |   for(int i = 0;i < v.size();i++)
      |                 ~~^~~~~~~~~~
./Main.cpp: In function ‘int main()’:
./Main.cpp:93:8: warning: unused variable ‘c’ [-Wunused-variable]
   93 |    int c = 0;
      |        ^
./Main.cpp: In function ‘void solve()’:
./Main.cpp:66:9: warning: ‘an’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   66 |      ll an;
      |         ^~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 63
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 7 ms 3508 KiB
example_01.txt AC 7 ms 3452 KiB
example_02.txt AC 2 ms 3596 KiB
hand_00.txt AC 14 ms 3504 KiB
hand_01.txt AC 4 ms 3536 KiB
hand_02.txt AC 18 ms 3512 KiB
hand_03.txt AC 13 ms 3516 KiB
hand_04.txt AC 14 ms 3508 KiB
hand_05.txt AC 14 ms 3544 KiB
hand_06.txt AC 12 ms 3512 KiB
hand_07.txt AC 14 ms 3548 KiB
hand_08.txt AC 14 ms 3560 KiB
hand_09.txt AC 14 ms 3612 KiB
hand_10.txt AC 13 ms 3560 KiB
hand_11.txt AC 19 ms 3556 KiB
hand_12.txt AC 15 ms 3512 KiB
hand_13.txt AC 17 ms 3508 KiB
hand_14.txt AC 17 ms 3608 KiB
hand_15.txt AC 16 ms 3456 KiB
hand_16.txt AC 15 ms 3608 KiB
hand_17.txt AC 16 ms 3516 KiB
hand_18.txt AC 13 ms 3548 KiB
hand_19.txt AC 13 ms 3576 KiB
hand_20.txt AC 12 ms 3564 KiB
hand_21.txt AC 12 ms 3512 KiB
hand_22.txt AC 21 ms 3592 KiB
hand_23.txt AC 15 ms 3560 KiB
hand_24.txt AC 12 ms 3560 KiB
hand_25.txt AC 6 ms 3576 KiB
hand_26.txt AC 11 ms 3508 KiB
random_00.txt AC 15 ms 3548 KiB
random_01.txt AC 13 ms 3608 KiB
random_02.txt AC 13 ms 3596 KiB
random_03.txt AC 13 ms 3504 KiB
random_04.txt AC 12 ms 3608 KiB
random_05.txt AC 13 ms 3508 KiB
random_06.txt AC 14 ms 3504 KiB
random_07.txt AC 13 ms 3444 KiB
random_08.txt AC 12 ms 3564 KiB
random_09.txt AC 12 ms 3596 KiB
random_10.txt AC 11 ms 3584 KiB
random_11.txt AC 7 ms 3508 KiB
random_12.txt AC 10 ms 3584 KiB
random_13.txt AC 14 ms 3604 KiB
random_14.txt AC 7 ms 3500 KiB
random_15.txt AC 14 ms 3560 KiB
random_16.txt AC 8 ms 3504 KiB
random_17.txt AC 10 ms 3564 KiB
random_18.txt AC 11 ms 3500 KiB
random_19.txt AC 8 ms 3504 KiB
random_20.txt AC 9 ms 3512 KiB
random_21.txt AC 12 ms 3512 KiB
random_22.txt AC 19 ms 3456 KiB
random_23.txt AC 11 ms 3508 KiB
random_24.txt AC 9 ms 3512 KiB
random_25.txt AC 11 ms 3512 KiB
random_26.txt AC 12 ms 3508 KiB
random_27.txt AC 2 ms 3572 KiB
random_28.txt AC 2 ms 3536 KiB
random_29.txt AC 2 ms 3508 KiB
random_30.txt AC 2 ms 3592 KiB
random_31.txt AC 1 ms 3560 KiB
random_32.txt AC 2 ms 3560 KiB