結果

問題 No.575 n! / m / m / m...
ユーザー imulanimulan
提出日時 2017-10-07 18:04:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,256 bytes
コンパイル時間 1,829 ms
コンパイル使用メモリ 174,664 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 12:52:05
合計ジャッジ時間 3,423 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
6,944 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 12 ms
6,944 KB
testcase_23 AC 13 ms
6,944 KB
testcase_24 AC 11 ms
6,940 KB
testcase_25 AC 11 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const double PI = acos(-1);

map<ll,int> factorize(ll n)
{
    map<ll,int> ret;

    ll t = n;
    for(ll i=2; i*i<=n; ++i)
    {
        while(t%i==0)
        {
            ++ret[i];
            t/=i;
        }
    }
    if(t>1) ++ret[t];

    return ret;
}

double stirling(ll n)
{
    return n*(log(n)-1) + log(sqrt(2*PI*n));
}

ll num(ll n, ll prime)
{
    ll a = prime;
    ll ret = 0;
    while(a<=n)
    {
        ret += n/a;
        a*=prime;
    }
    return ret;
}

int main()
{
    ll n,m;
    cin >>n >>m;

    ll ct = LLONG_MAX;
    for(const auto &p:factorize(m)) ct = min(ct, num(n,p.fi)/p.se);

    double v = stirling(n) - ct*log(m);
    v /= log(10);

    ll d = v;
    double ans = pow(10,v-d);

    printf("%.10fe%lld\n", ans,d);
    return 0;
}
0