結果
問題 | No.856 増える演算 |
ユーザー | ianCK |
提出日時 | 2020-01-01 03:21:49 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,172 bytes |
コンパイル時間 | 511 ms |
コンパイル使用メモリ | 46,976 KB |
実行使用メモリ | 8,008 KB |
最終ジャッジ日時 | 2024-05-01 03:19:42 |
合計ジャッジ時間 | 7,421 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
7,116 KB |
testcase_01 | AC | 44 ms
6,980 KB |
testcase_02 | AC | 44 ms
7,112 KB |
testcase_03 | AC | 44 ms
6,944 KB |
testcase_04 | AC | 44 ms
7,240 KB |
testcase_05 | AC | 43 ms
6,940 KB |
testcase_06 | AC | 44 ms
6,940 KB |
testcase_07 | AC | 44 ms
7,112 KB |
testcase_08 | AC | 44 ms
6,940 KB |
testcase_09 | AC | 43 ms
7,240 KB |
testcase_10 | AC | 43 ms
6,944 KB |
testcase_11 | AC | 43 ms
7,112 KB |
testcase_12 | AC | 43 ms
6,940 KB |
testcase_13 | AC | 43 ms
7,236 KB |
testcase_14 | AC | 43 ms
6,944 KB |
testcase_15 | AC | 47 ms
7,236 KB |
testcase_16 | AC | 43 ms
6,940 KB |
testcase_17 | AC | 44 ms
7,112 KB |
testcase_18 | AC | 43 ms
6,944 KB |
testcase_19 | AC | 44 ms
7,112 KB |
testcase_20 | AC | 45 ms
7,112 KB |
testcase_21 | AC | 44 ms
6,940 KB |
testcase_22 | AC | 43 ms
6,940 KB |
testcase_23 | AC | 46 ms
6,940 KB |
testcase_24 | AC | 47 ms
6,944 KB |
testcase_25 | AC | 44 ms
6,944 KB |
testcase_26 | AC | 43 ms
7,112 KB |
testcase_27 | AC | 43 ms
7,116 KB |
testcase_28 | AC | 46 ms
6,940 KB |
testcase_29 | AC | 46 ms
6,940 KB |
testcase_30 | AC | 44 ms
6,944 KB |
testcase_31 | AC | 44 ms
6,940 KB |
testcase_32 | AC | 46 ms
6,944 KB |
testcase_33 | AC | 49 ms
6,940 KB |
testcase_34 | AC | 53 ms
7,368 KB |
testcase_35 | AC | 50 ms
7,372 KB |
testcase_36 | AC | 52 ms
6,944 KB |
testcase_37 | AC | 52 ms
7,240 KB |
testcase_38 | AC | 45 ms
6,948 KB |
testcase_39 | AC | 45 ms
6,944 KB |
testcase_40 | AC | 47 ms
6,940 KB |
testcase_41 | AC | 48 ms
7,112 KB |
testcase_42 | AC | 54 ms
6,940 KB |
testcase_43 | AC | 47 ms
7,112 KB |
testcase_44 | AC | 44 ms
6,940 KB |
testcase_45 | AC | 45 ms
6,944 KB |
testcase_46 | AC | 48 ms
6,944 KB |
testcase_47 | AC | 47 ms
7,112 KB |
testcase_48 | AC | 50 ms
6,944 KB |
testcase_49 | AC | 48 ms
7,240 KB |
testcase_50 | AC | 50 ms
6,940 KB |
testcase_51 | AC | 52 ms
6,944 KB |
testcase_52 | AC | 53 ms
6,940 KB |
testcase_53 | AC | 74 ms
6,948 KB |
testcase_54 | AC | 61 ms
6,940 KB |
testcase_55 | AC | 73 ms
6,948 KB |
testcase_56 | AC | 60 ms
7,236 KB |
testcase_57 | AC | 76 ms
6,944 KB |
testcase_58 | AC | 69 ms
6,940 KB |
testcase_59 | AC | 85 ms
7,364 KB |
testcase_60 | AC | 64 ms
6,948 KB |
testcase_61 | AC | 85 ms
6,944 KB |
testcase_62 | AC | 82 ms
6,944 KB |
testcase_63 | AC | 47 ms
7,240 KB |
testcase_64 | AC | 80 ms
6,944 KB |
testcase_65 | AC | 57 ms
7,112 KB |
testcase_66 | AC | 65 ms
7,236 KB |
testcase_67 | AC | 71 ms
7,496 KB |
testcase_68 | AC | 88 ms
6,940 KB |
testcase_69 | AC | 82 ms
6,944 KB |
testcase_70 | AC | 89 ms
7,496 KB |
testcase_71 | AC | 81 ms
7,620 KB |
testcase_72 | AC | 77 ms
6,944 KB |
testcase_73 | AC | 94 ms
6,940 KB |
testcase_74 | AC | 91 ms
6,944 KB |
testcase_75 | AC | 92 ms
6,944 KB |
testcase_76 | AC | 93 ms
6,940 KB |
testcase_77 | AC | 92 ms
7,624 KB |
testcase_78 | AC | 93 ms
6,940 KB |
testcase_79 | AC | 94 ms
7,876 KB |
testcase_80 | AC | 93 ms
6,944 KB |
testcase_81 | AC | 92 ms
6,940 KB |
testcase_82 | WA | - |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:62:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 62 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:63:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 63 | for (int i = 1; i <= n; i++) scanf("%d", &a[i]); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <vector> #include <math.h> using namespace std; typedef long long int ll; constexpr int kMod = int(1E9 + 7), kN = 262144, kkMod = 1004535809; ll Pow(ll a, ll b, int p = kMod) { ll ans = 1; while (b) { if (b & 1) ans = ans * a % p; a = a * a % p; b >>= 1; } return ans; } void Ntt(vector<ll> &v, bool on, int sz) { ll wn, u, t, w, inv; for (int i = 1, j = sz >> 1, k; i < (sz - 1); i++) { if (i < j) swap(v[i], v[j]); k = sz >> 1; while (j & k) { j ^= k; k >>= 1; } j |= k; } for (int i = 2; i <= sz; i <<= 1) { wn = on ? Pow(3, (kkMod - 1) / i, kkMod) : Pow(3, kkMod - 1 - (kkMod - 1) / i, kkMod); for (int j = 0; j < sz; j += i) { w = 1; for (int k = j; k < j + (i >> 1); k++) { u = v[k]; t = (w * v[k + (i >> 1)]) % kkMod; v[k] = (u + t) % kkMod; v[k + (i >> 1)] = (u - t + kkMod) % kkMod; w = (w * wn) % kkMod; } } } if (on) { inv = Pow(sz, kkMod - 2, kkMod); for (int i = 0; i < sz; i++) v[i] = v[i] * inv % kkMod; } } int a[kN]; ll ts[kN]; bool Lesser(int ax, int ay, int bx, int by) { long double left = (ax + ay), right = (bx + by); left *= pow(ax, ay), right *= pow(bx, by); return left > right; } int main() { int n, l, r, nm; ll ans = 1, tmp = 1; vector<ll> v(kN); scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); ts[0] = 0; for (int i = 1; i <= n; i++) ts[i] = (ts[i - 1] + a[i]) % (kMod - 1); for (int i = 1; i <= n; i++) v[a[i]]++; Ntt(v, false, kN); for (int i = 0; i < kN; i++) v[i] = v[i] * v[i] % kkMod; Ntt(v, true, kN); for (int i = 1; i <= n; i++) v[a[i] << 1]--; for (int i = 1; i < kN; i++) v[i] >>= 1; for (int i = 1; i < kN; i++) tmp = tmp * Pow(i, v[i]) % kMod; for (int i = 1; i <= n; i++) ans = ans * Pow(a[i], ts[n] - ts[i] + kMod - 1) % kMod; l = a[n - 1], r = a[n], nm = a[n]; for (int i = n - 2; i >= 1; i--) { nm = min(nm, a[i + 1]); if (Lesser(l, r, a[i], nm)) { l = a[i]; r = nm; } } ans = ans * tmp % kMod; printf("%lld\n", ans * Pow((l + r) * Pow(l, r) % kMod, kMod - 2) % kMod); }