結果

問題 No.575 n! / m / m / m...
ユーザー rareonerareone
提出日時 2017-11-02 01:12:34
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,294 bytes
コンパイル時間 1,467 ms
コンパイル使用メモリ 158,056 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-02 04:27:39
合計ジャッジ時間 2,948 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 13 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 13 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 13 ms
5,376 KB
testcase_13 AC 12 ms
5,376 KB
testcase_14 AC 12 ms
5,376 KB
testcase_15 AC 13 ms
5,376 KB
testcase_16 AC 13 ms
5,376 KB
testcase_17 AC 13 ms
5,376 KB
testcase_18 AC 13 ms
5,376 KB
testcase_19 AC 13 ms
5,376 KB
testcase_20 AC 12 ms
5,376 KB
testcase_21 AC 12 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 12 ms
5,376 KB
testcase_24 WA -
testcase_25 AC 13 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In lambda function:
main.cpp:10:35: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 | auto scan = []{ static LL a; scanf("%lld", &a); return a;};
      |                              ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#ifdef __APPLE__
#include "bits:stdc++.h"
#else
#include <bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;
typedef pair<LL, LL> PLL;
auto scan = []{ static LL a; scanf("%lld", &a); return a;};

LL times(LL n, LL m) {
  LL ans = 1.1e18;
  for (LL p = 2; p * p <= 1e12+10; ++p) {
    LL cm = 0, col = 0;
    while (m % p == 0) ++cm, m /= p;
    if(cm == 0) continue;
    double check = m;
    for (LL cur = p; cur <= n && check <= n + 0.5; cur = cur * p, check = check * p) {
      col += n / cur;
    }
    ans = min(ans, col);
  }
  if (1 != m) {
    LL cm = 1, col = 0;
    double check = m;
    for (LL cur = m; cur <= n && check <= n + 0.5; cur = cur * m, check = check * m) {
      col += n / cur;
    }
    ans = min(ans, col);
  }
  return ans;
}


const double PI = acos(-1);
int main() {
  LL n = scan(), m = scan();
  if (n <= 10) {
    LL ans = 1;
    for (LL i = 1; i <= n; ++i) ans *= i;
    while (ans % m == 0) ans /= m;
    double lgans = log10(ans);
    LL flo = (LL) lgans;
    lgans -= flo;
    printf("%.2fe%lld\n",pow(10,lgans),flo);
  } else {
    double lgans = log10(sqrt(2 * PI * n)) + (log10(n) - log10(exp(1))) * n;
    lgans -= times(n,m) * log10(m);
    LL flo = 1LL * lgans;
    lgans -= flo;
    printf("%.2fe%lld\n",pow(10, lgans),flo);
  }
  
}
0