結果
問題 | No.1084 積の積 |
ユーザー | nebukuro09 |
提出日時 | 2020-06-19 23:06:24 |
言語 | D (dmd 2.106.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,221 bytes |
コンパイル時間 | 676 ms |
コンパイル使用メモリ | 108,988 KB |
実行使用メモリ | 11,660 KB |
最終ジャッジ日時 | 2023-09-04 08:15:02 |
合計ジャッジ時間 | 2,800 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 81 ms
8,456 KB |
testcase_05 | WA | - |
testcase_06 | AC | 81 ms
8,464 KB |
testcase_07 | WA | - |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 2 ms
4,380 KB |
testcase_12 | AC | 12 ms
5,520 KB |
testcase_13 | AC | 25 ms
8,004 KB |
testcase_14 | AC | 10 ms
5,188 KB |
testcase_15 | AC | 9 ms
5,908 KB |
testcase_16 | AC | 28 ms
8,916 KB |
testcase_17 | AC | 12 ms
5,352 KB |
testcase_18 | AC | 18 ms
6,360 KB |
testcase_19 | AC | 26 ms
7,900 KB |
testcase_20 | AC | 6 ms
4,376 KB |
testcase_21 | AC | 10 ms
5,696 KB |
testcase_22 | AC | 7 ms
4,380 KB |
testcase_23 | AC | 15 ms
5,916 KB |
testcase_24 | AC | 13 ms
5,784 KB |
testcase_25 | AC | 25 ms
7,992 KB |
testcase_26 | AC | 24 ms
8,576 KB |
testcase_27 | AC | 25 ms
9,580 KB |
testcase_28 | AC | 24 ms
8,360 KB |
testcase_29 | AC | 24 ms
7,900 KB |
testcase_30 | AC | 23 ms
8,892 KB |
testcase_31 | AC | 24 ms
8,644 KB |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdlib; immutable long mod = 10 ^^ 9 + 7; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!long).array; long ans = 1; foreach (a; A.split(0)) { ans = ans * solve(a.array) % mod; } ans.writeln; } long solve(long[] A) { int N = A.length.to!int; long tmp = 1; long ans = 1; auto imos = new long[](N+1); auto len = new long[](N+1); for (int i = 0, j = 0; i < N; ++i) { if (i > 0) tmp /= A[i-1]; while (j < N && tmp * A[j] < 10^^9) { tmp *= A[j++]; } if (i > 0) imos[i-1] -= 1; imos[j-1] += 1; len[i] = j - i; } foreach_reverse (i; 1..N) imos[i-1] += imos[i]; foreach_reverse(i; 1..N) imos[i-1] += imos[i] - len[i]; foreach (i; 0..N) ans = ans * powmod(A[i], imos[i], mod) % mod; return ans; } long powmod(long a, long x, long m) { long ret = 1; while (x) { if (x % 2) ret = ret * a % m; a = a * a % m; x /= 2; } return ret; }