結果
問題 | No.856 増える演算 |
ユーザー | ianCK |
提出日時 | 2020-01-01 03:52:35 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 102 ms / 3,153 ms |
コード長 | 2,284 bytes |
コンパイル時間 | 923 ms |
コンパイル使用メモリ | 73,668 KB |
実行使用メモリ | 9,924 KB |
最終ジャッジ日時 | 2024-05-01 04:10:07 |
合計ジャッジ時間 | 7,990 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
7,184 KB |
testcase_01 | AC | 32 ms
9,160 KB |
testcase_02 | AC | 32 ms
9,160 KB |
testcase_03 | AC | 32 ms
9,164 KB |
testcase_04 | AC | 32 ms
7,000 KB |
testcase_05 | AC | 32 ms
7,192 KB |
testcase_06 | AC | 35 ms
7,016 KB |
testcase_07 | AC | 32 ms
7,012 KB |
testcase_08 | AC | 32 ms
7,008 KB |
testcase_09 | AC | 39 ms
7,296 KB |
testcase_10 | AC | 31 ms
7,124 KB |
testcase_11 | AC | 32 ms
9,160 KB |
testcase_12 | AC | 32 ms
7,176 KB |
testcase_13 | AC | 32 ms
9,288 KB |
testcase_14 | AC | 32 ms
7,376 KB |
testcase_15 | AC | 32 ms
7,240 KB |
testcase_16 | AC | 32 ms
7,164 KB |
testcase_17 | AC | 31 ms
7,220 KB |
testcase_18 | AC | 32 ms
9,160 KB |
testcase_19 | AC | 32 ms
9,288 KB |
testcase_20 | AC | 32 ms
9,284 KB |
testcase_21 | AC | 31 ms
7,184 KB |
testcase_22 | AC | 32 ms
7,128 KB |
testcase_23 | AC | 34 ms
7,224 KB |
testcase_24 | AC | 35 ms
9,288 KB |
testcase_25 | AC | 32 ms
7,016 KB |
testcase_26 | AC | 32 ms
9,288 KB |
testcase_27 | AC | 32 ms
7,160 KB |
testcase_28 | AC | 34 ms
7,256 KB |
testcase_29 | AC | 34 ms
9,288 KB |
testcase_30 | AC | 34 ms
7,132 KB |
testcase_31 | AC | 34 ms
7,152 KB |
testcase_32 | AC | 35 ms
7,356 KB |
testcase_33 | AC | 36 ms
7,340 KB |
testcase_34 | AC | 41 ms
7,540 KB |
testcase_35 | AC | 38 ms
7,252 KB |
testcase_36 | AC | 40 ms
7,328 KB |
testcase_37 | AC | 39 ms
7,416 KB |
testcase_38 | AC | 34 ms
7,160 KB |
testcase_39 | AC | 34 ms
7,136 KB |
testcase_40 | AC | 35 ms
7,304 KB |
testcase_41 | AC | 38 ms
7,356 KB |
testcase_42 | AC | 42 ms
7,532 KB |
testcase_43 | AC | 36 ms
9,284 KB |
testcase_44 | AC | 33 ms
7,016 KB |
testcase_45 | AC | 33 ms
9,160 KB |
testcase_46 | AC | 35 ms
7,336 KB |
testcase_47 | AC | 36 ms
9,284 KB |
testcase_48 | AC | 38 ms
7,404 KB |
testcase_49 | AC | 36 ms
7,292 KB |
testcase_50 | AC | 39 ms
7,256 KB |
testcase_51 | AC | 41 ms
7,396 KB |
testcase_52 | AC | 41 ms
7,476 KB |
testcase_53 | AC | 64 ms
9,668 KB |
testcase_54 | AC | 51 ms
7,336 KB |
testcase_55 | AC | 61 ms
7,592 KB |
testcase_56 | AC | 49 ms
9,416 KB |
testcase_57 | AC | 67 ms
9,416 KB |
testcase_58 | AC | 59 ms
7,748 KB |
testcase_59 | AC | 75 ms
9,540 KB |
testcase_60 | AC | 57 ms
7,532 KB |
testcase_61 | AC | 75 ms
9,924 KB |
testcase_62 | AC | 72 ms
8,192 KB |
testcase_63 | AC | 38 ms
7,160 KB |
testcase_64 | AC | 70 ms
9,548 KB |
testcase_65 | AC | 47 ms
7,364 KB |
testcase_66 | AC | 54 ms
7,476 KB |
testcase_67 | AC | 60 ms
7,528 KB |
testcase_68 | AC | 71 ms
9,676 KB |
testcase_69 | AC | 69 ms
9,416 KB |
testcase_70 | AC | 79 ms
8,200 KB |
testcase_71 | AC | 73 ms
7,984 KB |
testcase_72 | AC | 68 ms
7,816 KB |
testcase_73 | AC | 83 ms
8,312 KB |
testcase_74 | AC | 82 ms
9,548 KB |
testcase_75 | AC | 81 ms
8,228 KB |
testcase_76 | AC | 83 ms
8,368 KB |
testcase_77 | AC | 82 ms
8,340 KB |
testcase_78 | AC | 81 ms
8,328 KB |
testcase_79 | AC | 82 ms
8,392 KB |
testcase_80 | AC | 82 ms
9,804 KB |
testcase_81 | AC | 83 ms
8,288 KB |
testcase_82 | AC | 102 ms
8,320 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:64:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 64 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:65:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 65 | for (int i = 1; i <= n; i++) scanf("%d", &a[i]); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <vector> #include <math.h> #include <complex> using namespace std; typedef long long int ll; constexpr int kMod = int(1E9 + 7), kN = 262144; constexpr double pi = acos(-1); constexpr complex<double> one = complex<double>(1, 0), half = complex<double>(0.5, 0); ll Pow(ll a, ll b) { ll ans = 1; while (b) { if (b & 1) ans = ans * a % kMod; a = a * a % kMod; b >>= 1; } return ans; } void FFT(vector<complex<double>> &v, bool on, int sz) { complex<double> wn, u, t, w, inv(1.0 / sz, 0); 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 ? complex<double>(cos(2 * pi / i), -sin(2 * pi / i)) : complex<double>(cos(2 * pi / i), sin(2 * pi / i)); 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)]; v[k] = u + t; v[k + (i >> 1)] = u - t; w *= wn; } } } if (on) for (int i = 0; i < sz; i++) v[i] *= inv; } 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<complex<double>> 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]] += one; FFT(v, false, kN); for (int i = 0; i < kN; i++) v[i] = v[i] * v[i]; FFT(v, true, kN); for (int i = 1; i <= n; i++) v[a[i] << 1] -= one; for (int i = 1; i < kN; i++) v[i] *= half; for (int i = 1; i < kN; i++) tmp = tmp * Pow(i, ll(v[i].real() + 0.5)) % 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); }