結果

問題 No.575 n! / m / m / m...
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-10-07 10:48:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,962 bytes
コンパイル時間 1,472 ms
コンパイル使用メモリ 171,968 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-10 19:25:05
合計ジャッジ時間 3,563 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
typedef long long ll;
map<ll,int> enumpr(ll n) {
	map<ll,int> V;
	for(ll i=2;i*i<=n;i++) while(n%i==0) V[i]++,n/=i;
	if(n>1) V[n]++;
	return V;
}
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/




ll N, M;
//---------------------------------------------------------------------------------------------------
const double PI = 2 * acos(0.0), E = exp(1);
// スターリングの近似公式を使ってlog10(n!)を計算する
double log10facn(double n) {
    return log10(2 * PI * N) / 2 + n * log10(n / E) + log10(1 + 1.0 / (12 * N));
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;

    auto e = enumpr(M);
    ll k = 10101010;
    fore(p, e) {
        ll x = p.first;
        ll c = 0;
        while (x <= M) {
            c += N / x;
            x *= x;
        }
        k = min(k, c / p.second);
    }

    double a = log10facn(N);
    double b = log10(M);

    double n = a - b * k;

    ll d = floor(n);

    n -= d;
    
    double nn = pow(10, n);
    printf("%.10fe%lld\n", nn, d);
}
0