結果
問題 | No.2811 Calculation Within Sequence |
ユーザー | ks2m |
提出日時 | 2024-07-19 21:26:17 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 533 ms / 2,000 ms |
コード長 | 889 bytes |
コンパイル時間 | 2,938 ms |
コンパイル使用メモリ | 75,868 KB |
実行使用メモリ | 65,632 KB |
最終ジャッジ日時 | 2024-07-19 21:26:53 |
合計ジャッジ時間 | 22,066 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
37,228 KB |
testcase_01 | AC | 52 ms
36,776 KB |
testcase_02 | AC | 53 ms
36,780 KB |
testcase_03 | AC | 489 ms
64,724 KB |
testcase_04 | AC | 515 ms
65,272 KB |
testcase_05 | AC | 492 ms
65,128 KB |
testcase_06 | AC | 495 ms
65,384 KB |
testcase_07 | AC | 516 ms
64,332 KB |
testcase_08 | AC | 520 ms
64,720 KB |
testcase_09 | AC | 511 ms
64,652 KB |
testcase_10 | AC | 504 ms
65,632 KB |
testcase_11 | AC | 533 ms
65,072 KB |
testcase_12 | AC | 502 ms
64,520 KB |
testcase_13 | AC | 520 ms
65,344 KB |
testcase_14 | AC | 485 ms
64,764 KB |
testcase_15 | AC | 530 ms
65,292 KB |
testcase_16 | AC | 484 ms
65,012 KB |
testcase_17 | AC | 449 ms
63,548 KB |
testcase_18 | AC | 500 ms
64,768 KB |
testcase_19 | AC | 512 ms
64,448 KB |
testcase_20 | AC | 491 ms
65,152 KB |
testcase_21 | AC | 497 ms
63,808 KB |
testcase_22 | AC | 448 ms
64,112 KB |
testcase_23 | AC | 481 ms
64,504 KB |
testcase_24 | AC | 368 ms
60,880 KB |
testcase_25 | AC | 238 ms
49,084 KB |
testcase_26 | AC | 229 ms
48,452 KB |
testcase_27 | AC | 379 ms
63,056 KB |
testcase_28 | AC | 161 ms
44,672 KB |
testcase_29 | AC | 339 ms
54,468 KB |
testcase_30 | AC | 330 ms
60,312 KB |
testcase_31 | AC | 322 ms
57,092 KB |
testcase_32 | AC | 194 ms
46,260 KB |
testcase_33 | AC | 316 ms
55,564 KB |
testcase_34 | AC | 388 ms
60,612 KB |
testcase_35 | AC | 272 ms
51,572 KB |
testcase_36 | AC | 310 ms
54,312 KB |
testcase_37 | AC | 290 ms
50,848 KB |
testcase_38 | AC | 286 ms
55,228 KB |
testcase_39 | AC | 308 ms
53,940 KB |
testcase_40 | AC | 341 ms
62,040 KB |
testcase_41 | AC | 389 ms
63,888 KB |
testcase_42 | AC | 242 ms
51,712 KB |
testcase_43 | AC | 322 ms
56,452 KB |
ソースコード
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int a = Integer.parseInt(sa[0]); int b = Integer.parseInt(sa[1]); sa = br.readLine().split(" "); int[] t = new int[a]; for (int i = 0; i < a; i++) { t[i] = Integer.parseInt(sa[i]); } sa = br.readLine().split(" "); int[] s = new int[b]; for (int i = 0; i < b; i++) { s[i] = Integer.parseInt(sa[i]); } br.close(); int g = 0; for (int i = 0; i < a; i++) { g = gcd(g, t[i]); } for (int i = 0; i < b; i++) { if (s[i] % g != 0) { System.out.println("No"); return; } } System.out.println("Yes"); } static int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } }