結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー Manuel1024
提出日時 2021-04-22 18:28:36
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 670 bytes
コンパイル時間 3,793 ms
コンパイル使用メモリ 74,552 KB
実行使用メモリ 47,416 KB
最終ジャッジ日時 2024-12-14 21:25:02
合計ジャッジ時間 14,425 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();
        for(int q = 0; q < t; q++){
          int n = sc.nextInt();
          int m = sc.nextInt();
          int[] a = new int[n];
          int[] b = new int[m];
          for(int i = 0; i < n; i++) a[i] = sc.nextInt();
          for(int i = 0; i < m; i++) b[i] = sc.nextInt();
          int ans = -1;
          for(int i = 0; i < n*m; i++){
            if(a[i%n] == b[i%m]){
              ans = i+1;
              break;
            }
          }
          System.out.println(ans);
        }
    }
}
0