結果
問題 | No.1544 [Cherry 2nd Tune C] Synchroscope |
ユーザー |
![]() |
提出日時 | 2021-06-11 21:54:44 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 505 ms / 2,000 ms |
コード長 | 541 bytes |
コンパイル時間 | 2,203 ms |
コンパイル使用メモリ | 74,272 KB |
実行使用メモリ | 58,760 KB |
最終ジャッジ日時 | 2024-12-14 23:22:52 |
合計ジャッジ時間 | 17,316 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 48 |
ソースコード
import java.util.Scanner;public class Main {public static void main(String[] args) throws Exception {Scanner sc = new Scanner(System.in);int n = sc.nextInt();int m = sc.nextInt();int[] a = new int[n];for (int i = 0; i < n; i++) {a[i] = sc.nextInt();}int[] b = new int[m];for (int i = 0; i < m; i++) {b[i] = sc.nextInt();}sc.close();int nm = n * m;for (int i = 0; i < nm; i++) {if (a[i % n] == b[i % m]) {System.out.println(i + 1);return;}}System.out.println(-1);}}