結果
問題 | No.1140 EXPotentiaLLL! |
ユーザー | shi-mo |
提出日時 | 2020-10-01 00:50:51 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 619 ms / 2,000 ms |
コード長 | 750 bytes |
コンパイル時間 | 1,424 ms |
コンパイル使用メモリ | 142,596 KB |
実行使用メモリ | 8,656 KB |
最終ジャッジ日時 | 2023-09-04 10:12:09 |
合計ジャッジ時間 | 8,209 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 609 ms
8,368 KB |
testcase_01 | AC | 533 ms
7,812 KB |
testcase_02 | AC | 599 ms
8,604 KB |
testcase_03 | AC | 400 ms
8,360 KB |
testcase_04 | AC | 316 ms
8,656 KB |
testcase_05 | AC | 481 ms
7,824 KB |
testcase_06 | AC | 460 ms
8,400 KB |
testcase_07 | AC | 619 ms
8,580 KB |
testcase_08 | AC | 40 ms
7,828 KB |
testcase_09 | AC | 39 ms
8,364 KB |
testcase_10 | AC | 40 ms
7,876 KB |
testcase_11 | AC | 39 ms
7,520 KB |
testcase_12 | AC | 39 ms
8,184 KB |
コンパイルメッセージ
/dmd2/linux/bin64/../../src/phobos/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!ulong.gcdImpl`
ソースコード
import std.stdio; import std.algorithm; import std.array; import std.math; import std.numeric; bool[] notPrime; void main() { uint t; readf("%s\n", &t); const int PMAX = 5000000; notPrime = generateNotPrime(PMAX); foreach(i; 0..t) { ulong a; uint p; readf("%s %s\n", &a, &p); if (notPrime[p]) { writeln("-1"); continue; } writeln((1 == gcd(a, p)) ? 1 : 0); } } bool[] generateNotPrime(uint n) { bool[] notPrime = []; notPrime.length = n + 1; notPrime[1] = true; foreach (i; 2..(n+1)) { if (notPrime[i]) { continue; } for (uint j = i*2; j <= n; j += i) { notPrime[j] = true; } } return notPrime; }