結果
問題 | No.1084 積の積 |
ユーザー | kibuna |
提出日時 | 2020-06-19 22:01:17 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,730 bytes |
コンパイル時間 | 1,748 ms |
コンパイル使用メモリ | 172,400 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-03 14:35:31 |
合計ジャッジ時間 | 3,407 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 23 ms
6,940 KB |
testcase_05 | RE | - |
testcase_06 | AC | 23 ms
6,940 KB |
testcase_07 | RE | - |
testcase_08 | AC | 3 ms
6,940 KB |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 8 ms
6,940 KB |
testcase_13 | WA | - |
testcase_14 | AC | 6 ms
6,944 KB |
testcase_15 | AC | 6 ms
6,940 KB |
testcase_16 | WA | - |
testcase_17 | AC | 7 ms
6,940 KB |
testcase_18 | AC | 10 ms
6,944 KB |
testcase_19 | WA | - |
testcase_20 | AC | 5 ms
6,940 KB |
testcase_21 | AC | 6 ms
6,940 KB |
testcase_22 | AC | 5 ms
6,944 KB |
testcase_23 | AC | 9 ms
6,944 KB |
testcase_24 | AC | 8 ms
6,944 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using lint = long long; const lint inf = 1LL << 60; const lint mod = 1000000007; template <int mod> struct modint { lint v; modint() : v(0) {} modint(signed v) : v(v) {} modint(lint t) { v = t % mod; if (v < 0) v += mod; } modint pow(lint k) { modint res(1), tmp(v); while (k) { if (k & 1) res *= tmp; tmp *= tmp; k >>= 1; } return res; } static modint add_identity() { return modint(0); } static modint mul_identity() { return modint(1); } modint inv() { return pow(mod - 2); } modint &operator+=(modint a) { v += a.v; if (v >= mod) v -= mod; return *this; } modint &operator-=(modint a) { v += mod - a.v; if (v >= mod) v -= mod; return *this; } modint &operator*=(modint a) { v = v * a.v % mod; return *this; } modint &operator/=(modint a) { return (*this) *= a.inv(); } modint operator+(modint a) const { return modint(v) += a; }; modint operator-(modint a) const { return modint(v) -= a; }; modint operator*(modint a) const { return modint(v) *= a; }; modint operator/(modint a) const { return modint(v) /= a; }; modint operator-() const { return v ? modint(mod - v) : modint(v); } bool operator==(const modint a) const { return v == a.v; } bool operator!=(const modint a) const { return v != a.v; } bool operator<(const modint a) const { return v < a.v; } }; using mint = modint<mod>; ostream &operator<<(ostream &os, mint m) { return os << m.v; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); lint n; cin >> n; vector<lint> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } lint curr = 1; lint l = 0; vector<int> ri(n + 1, 0), ri2(n + 1, 0); for (int i = 0; i < n; ++i) { while (l < n && curr < 1000000000) { curr *= a[l]; l++; } if (curr >= 1000000000) { if (i) ri2[i - 1] -= (n - 1 - (l - 2)); ri[l - 2]--; ri[n - 1]++; } curr /= a[i]; } for (int i = n - 1; i >= 0; --i) { ri[i] += ri[i + 1]; ri2[i] += ri2[i + 1]; } for (int i = n - 1; i >= 0; --i) { ri[i] += ri[i + 1]; } mint ret = 1; for (int i = 0; i < n; ++i) { ret *= mint(a[i]).pow((i + 1) * (n - i) - ri[i] - ri2[i]); } // for (int i = 0; i < n; ++i) { // ret /= mint(a[i]).pow(ri[i] + ri2[i]); // } cout << ret << "\n"; return 0; }