結果
| 問題 |
No.1544 [Cherry 2nd Tune C] Synchroscope
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-06 08:51:13 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 472 ms / 2,000 ms |
| コード長 | 841 bytes |
| コンパイル時間 | 2,076 ms |
| コンパイル使用メモリ | 74,704 KB |
| 実行使用メモリ | 47,896 KB |
| 最終ジャッジ日時 | 2024-07-04 14:56:21 |
| 合計ジャッジ時間 | 16,401 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 48 |
ソースコード
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[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;
}
}
output.print(ans);
output.flush();
}
}