結果
問題 | No.856 増える演算 |
ユーザー | QCFium |
提出日時 | 2019-10-08 17:50:34 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,714 bytes |
コンパイル時間 | 1,878 ms |
コンパイル使用メモリ | 178,456 KB |
実行使用メモリ | 9,472 KB |
最終ジャッジ日時 | 2024-11-07 07:32:42 |
合計ジャッジ時間 | 11,816 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 57 ms
7,024 KB |
testcase_01 | AC | 57 ms
7,024 KB |
testcase_02 | AC | 56 ms
7,152 KB |
testcase_03 | AC | 57 ms
7,280 KB |
testcase_04 | AC | 57 ms
7,148 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 57 ms
7,280 KB |
testcase_08 | AC | 57 ms
7,036 KB |
testcase_09 | WA | - |
testcase_10 | AC | 56 ms
7,156 KB |
testcase_11 | AC | 58 ms
7,064 KB |
testcase_12 | AC | 57 ms
7,152 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 59 ms
7,224 KB |
testcase_24 | AC | 60 ms
7,296 KB |
testcase_25 | AC | 57 ms
7,264 KB |
testcase_26 | AC | 56 ms
7,164 KB |
testcase_27 | AC | 57 ms
7,156 KB |
testcase_28 | AC | 60 ms
7,536 KB |
testcase_29 | AC | 60 ms
7,424 KB |
testcase_30 | AC | 59 ms
7,416 KB |
testcase_31 | AC | 56 ms
7,164 KB |
testcase_32 | AC | 59 ms
7,232 KB |
testcase_33 | AC | 64 ms
7,664 KB |
testcase_34 | AC | 74 ms
7,524 KB |
testcase_35 | AC | 67 ms
7,392 KB |
testcase_36 | AC | 74 ms
7,524 KB |
testcase_37 | AC | 70 ms
7,584 KB |
testcase_38 | AC | 58 ms
7,400 KB |
testcase_39 | AC | 60 ms
7,424 KB |
testcase_40 | AC | 62 ms
7,312 KB |
testcase_41 | AC | 63 ms
7,472 KB |
testcase_42 | AC | 78 ms
7,804 KB |
testcase_43 | AC | 62 ms
7,360 KB |
testcase_44 | WA | - |
testcase_45 | AC | 60 ms
7,268 KB |
testcase_46 | AC | 64 ms
7,288 KB |
testcase_47 | AC | 62 ms
7,212 KB |
testcase_48 | AC | 69 ms
7,352 KB |
testcase_49 | AC | 65 ms
7,500 KB |
testcase_50 | AC | 71 ms
7,572 KB |
testcase_51 | AC | 76 ms
7,704 KB |
testcase_52 | AC | 77 ms
7,848 KB |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | WA | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | WA | - |
ソースコード
#include <bits/stdc++.h> int ri() { int n; scanf("%d", &n); return n; } int pow(int a, int b, int mod) { int res = 1; for (; b; b >>= 1) { if (b & 1) res = (int64_t) res * a % mod; a = (int64_t) a * a % mod; } return res; } int inv(int i, int mod) { return pow(i, mod - 2, mod); } template<int mod, int proot> struct NTT { int get_mod() { return mod; } void ntt(std::vector<int> &a, bool inverse) { int n = a.size(); assert((n & -n) == n); int h = pow(proot, (mod - 1) / n, mod); if (inverse) h = inv(h, mod); for (int i = 0, j = 1; j < n - 1; j++) { for (int k = n >> 1; k > (i ^= k); k >>= 1); if (j < i) std::swap(a[i], a[j]); } for (int i = 1; i < n; i <<= 1) { int base = pow(h, n / i / 2, mod); int w = 1; for (int j = 0; j < i; j++) { for (int k = j; k < n; k += i << 1) { int u = a[k]; int d = (int64_t) a[k + i] * w % mod; a[k] = u + d; if (a[k] >= mod) a[k] -= mod; a[k + i] = u - d; if (a[k + i] < 0) a[k + i] += mod; } w = (int64_t) w * base % mod; } } if (inverse) { int ninv = inv(a.size(), mod); for (auto &i : a) i = (int64_t) i * ninv % mod; } } std::vector<int> conv(const std::vector<int> a_, const std::vector<int> b_) { std::vector<int> a = a_, b = b_; size_t size = 1; for (; size < a_.size() + b_.size(); size <<= 1); a.resize(size); b.resize(size); ntt(a, false); ntt(b, false); for (size_t i = 0; i < size; i++) a[i] = (int64_t) a[i] * b[i] % mod; ntt(a, true); a.resize(a_.size() + b_.size() - 1); return a; } }; #define MOD 1000000007 int main() { int n = ri(); int a[n]; for (int i = 0; i < n; i++) a[i] = ri(); std::multiset<std::pair<int, int> > all; for (int i = 0; i < n; i++) all.insert({a[i], i}); std::pair<int, int> optimal; double min = 1000000000; for (int i = 0; i < n; i++) { all.erase(all.find({a[i], i})); double cur = log(a[i]) * all.begin()->first; if (min > cur) min = cur, optimal = {i, all.begin()->second}; } int64_t sum[n]; sum[n - 1] = 0; for (int i = n - 2; i >= 0; i--) sum[i] = sum[i + 1] + a[i + 1]; int res = 1; for (int i = 0; i < n; i++) res = (int64_t) res * pow(a[i], sum[i] % (MOD - 1), MOD) % MOD; std::vector<int> num(100001); for (int i = 0; i < n; i++) num[a[i]]++; NTT<998244353, 3> ntt; auto conv = ntt.conv(num, num); for (int i = 0; i < n; i++) conv[a[i] + a[i]]--; for (int i = 1; i <= 100000; i++) assert(conv[i] % 2 == 0), conv[i] >>= 1, res = (int64_t) res * pow(i, conv[i], MOD) % MOD; res = (int64_t) res * inv((int64_t) (a[optimal.first] + a[optimal.second]) * pow(a[optimal.first], a[optimal.second], MOD) % MOD, MOD) % MOD; std::cout << res << std::endl; return 0; }