結果
| 問題 | No.2811 Calculation Within Sequence |
| コンテスト | |
| ユーザー |
highlighter
|
| 提出日時 | 2024-07-04 11:24:52 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 695 ms / 2,000 ms |
| コード長 | 529 bytes |
| 記録 | |
| コンパイル時間 | 2,361 ms |
| コンパイル使用メモリ | 82,364 KB |
| 実行使用メモリ | 63,096 KB |
| 最終ジャッジ日時 | 2026-04-03 20:06:45 |
| 合計ジャッジ時間 | 28,189 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
import java.util.Scanner;
public class Main {
public static int gcd(int m,int n){
int r;
while(n > 0){
r=m%n;
m=n;
n=r;
}
return m;
}
public static void main(String[] args){
var sc=new java.util.Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int t=0;
for(int i=0;i<a;i++){
int T=sc.nextInt();
t=gcd(t,T);
}
int s=0;
for(int i=0;i<b;i++){
int S=sc.nextInt();
s=gcd(s,S);
}
if(s%t==0){
System.out.println("Yes");
}
else{
System.out.println("No");
}
}
}
highlighter