結果
問題 | No.575 n! / m / m / m... |
ユーザー | Pachicobue |
提出日時 | 2017-10-07 02:52:08 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,340 bytes |
コンパイル時間 | 1,866 ms |
コンパイル使用メモリ | 170,592 KB |
実行使用メモリ | 14,424 KB |
最終ジャッジ日時 | 2024-11-17 03:20:51 |
合計ジャッジ時間 | 4,690 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
12,904 KB |
testcase_01 | WA | - |
testcase_02 | AC | 27 ms
12,688 KB |
testcase_03 | AC | 28 ms
14,152 KB |
testcase_04 | AC | 27 ms
14,424 KB |
testcase_05 | AC | 28 ms
13,892 KB |
testcase_06 | AC | 28 ms
13,232 KB |
testcase_07 | AC | 26 ms
12,656 KB |
testcase_08 | AC | 27 ms
13,748 KB |
testcase_09 | AC | 27 ms
12,656 KB |
testcase_10 | AC | 28 ms
13,608 KB |
testcase_11 | AC | 26 ms
12,588 KB |
testcase_12 | AC | 27 ms
12,900 KB |
testcase_13 | AC | 27 ms
12,936 KB |
testcase_14 | AC | 28 ms
13,888 KB |
testcase_15 | AC | 28 ms
13,112 KB |
testcase_16 | AC | 28 ms
13,500 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
ソースコード
#include <bits/stdc++.h> #define show(x) cerr << #x << " = " << x << endl using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "sz=" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template <typename S, typename T> ostream& operator<<(ostream& os, const pair<S, T>& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = 1e9 + 7; template <typename T> constexpr T INF = numeric_limits<T>::max() / 100; constexpr ll MAX = (ll)1e12; constexpr ll SQRT = (ll)1e6; bool isprime[SQRT + 1]; long double logsum(const ll n) { long double sum = 0; constexpr ll LEV = 1000000; for (ll i = 2; i <= min(LEV, n); i++) { sum += (long double)log2(i); } if (n > LEV) { sum += n * (long double)log2(n) - LEV * (long double)log2(LEV) - n + LEV; } return sum; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, m; cin >> n >> m; fill(isprime, isprime + SQRT + 1, true); for (ll i = 2; i <= SQRT; i++) { if (isprime[i]) { for (ll j = 2; i * j <= SQRT; j++) { isprime[i * j] = false; } } } vector<ll> prime; for (ll i = 2; i <= SQRT; i++) { prime.push_back(i); } ll cnt = INF<ll>; ll m_cop = m; for (const ll p : prime) { if (m_cop % p != 0) { continue; } ll d = 0; while (m_cop % p == 0) { d++; m_cop /= p; } ll candiv = 0; ll n_cop = n; while (n_cop > 0) { candiv += n_cop / p; n_cop /= p; } cnt = min(cnt, candiv / d); } if (m_cop > 1) { ll candiv = 0; ll n_cop = n; while (n_cop > 0) { candiv += n_cop / m_cop; n_cop /= m_cop; } cnt = min(cnt, candiv); } const long double restlog = logsum(n) - cnt * (long double)log2(m); const ll d = (ll)(restlog / log2(10)); const long double rest = restlog - log2(10) * d; cout << fixed << setprecision(10) << pow(2, rest) << "e" << d << endl; return 0; }