結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー AsahiAsahi
提出日時 2023-02-06 08:54:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 582 ms / 2,000 ms
コード長 966 bytes
コンパイル時間 2,025 ms
コンパイル使用メモリ 73,880 KB
実行使用メモリ 264,252 KB
最終ジャッジ日時 2023-09-17 20:56:04
合計ジャッジ時間 23,642 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
53,816 KB
testcase_01 AC 121 ms
55,568 KB
testcase_02 AC 120 ms
56,240 KB
testcase_03 AC 349 ms
108,676 KB
testcase_04 AC 449 ms
174,828 KB
testcase_05 AC 379 ms
132,024 KB
testcase_06 AC 438 ms
157,528 KB
testcase_07 AC 401 ms
155,060 KB
testcase_08 AC 362 ms
119,252 KB
testcase_09 AC 241 ms
65,524 KB
testcase_10 AC 422 ms
153,420 KB
testcase_11 AC 360 ms
114,480 KB
testcase_12 AC 344 ms
106,128 KB
testcase_13 AC 243 ms
66,168 KB
testcase_14 AC 444 ms
185,784 KB
testcase_15 AC 476 ms
209,752 KB
testcase_16 AC 346 ms
104,648 KB
testcase_17 AC 311 ms
85,648 KB
testcase_18 AC 229 ms
63,452 KB
testcase_19 AC 244 ms
70,524 KB
testcase_20 AC 471 ms
181,972 KB
testcase_21 AC 304 ms
81,360 KB
testcase_22 AC 235 ms
66,076 KB
testcase_23 AC 554 ms
264,252 KB
testcase_24 AC 537 ms
263,212 KB
testcase_25 AC 558 ms
263,496 KB
testcase_26 AC 531 ms
264,056 KB
testcase_27 AC 531 ms
263,928 KB
testcase_28 AC 536 ms
264,052 KB
testcase_29 AC 530 ms
263,424 KB
testcase_30 AC 569 ms
263,836 KB
testcase_31 AC 535 ms
262,936 KB
testcase_32 AC 538 ms
263,172 KB
testcase_33 AC 562 ms
263,136 KB
testcase_34 AC 122 ms
55,816 KB
testcase_35 AC 121 ms
55,812 KB
testcase_36 AC 207 ms
59,616 KB
testcase_37 AC 206 ms
59,004 KB
testcase_38 AC 558 ms
263,292 KB
testcase_39 AC 556 ms
260,888 KB
testcase_40 AC 582 ms
263,032 KB
testcase_41 AC 580 ms
263,952 KB
testcase_42 AC 572 ms
259,324 KB
testcase_43 AC 571 ms
249,296 KB
testcase_44 AC 547 ms
251,780 KB
testcase_45 AC 553 ms
261,180 KB
testcase_46 AC 567 ms
253,032 KB
testcase_47 AC 565 ms
255,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;
// import java.util.stream.Stream;

class Main{
    static BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static PrintWriter output = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws IOException{
        int n = sc.nextInt();
        int m = sc.nextInt();
        int MAX = n*m;
        int [] a = new int[MAX+1];
        int [] b = new int[MAX+1];
        for(int i=0;i<n;i++) a[i] = sc.nextInt();
        for(int i=0;i<m;i++) b[i] = sc.nextInt();
        for(int i=0;i<MAX+1;i++) a[i] = a[i%n];
        for(int i=0;i<MAX+1;i++) b[i] = b[i%m];
        int ans = -1;
        for(int i=0;i<MAX+1;i++) {
            if(a[i] == b[i]) {
                ans = i+1;
                break;
            }
        }
        output.print(ans);
        output.flush();
    }
}
0