結果
| 問題 |
No.2811 Calculation Within Sequence
|
| コンテスト | |
| ユーザー |
highlighter
|
| 提出日時 | 2024-07-04 11:24:52 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 1,047 ms / 2,000 ms |
| コード長 | 529 bytes |
| コンパイル時間 | 4,410 ms |
| コンパイル使用メモリ | 74,244 KB |
| 実行使用メモリ | 70,020 KB |
| 最終ジャッジ日時 | 2024-08-06 01:52:21 |
| 合計ジャッジ時間 | 43,148 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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