結果
問題 |
No.1544 [Cherry 2nd Tune C] Synchroscope
|
ユーザー |
|
提出日時 | 2023-02-06 08:45:19 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 953 bytes |
コンパイル時間 | 2,243 ms |
コンパイル使用メモリ | 77,580 KB |
実行使用メモリ | 55,600 KB |
最終ジャッジ日時 | 2024-07-04 14:51:46 |
合計ジャッジ時間 | 17,464 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 38 WA * 10 |
ソースコード
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 [] a = new int[1000000]; int [] b = new int[1000000]; 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<1000000;i++) a[i] = a[i%n]; for(int i=0;i<1000000;i++) b[i] = b[i%m]; int ans = -1; for(int i=0;i<1000000;i++) { if(a[i] == b[i]) { ans = i+1; break; } } output.print(ans); output.flush(); } }