結果
| 問題 | No.2821 A[i] ← 2A[j] - A[i] |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-07 00:53:43 |
| 言語 | Java (openjdk 26.0.2.1 + ac-library) |
| 結果 |
AC
不安定
|
| 実行時間 | 697 ms / 1,500 ms |
| + 661µs | |
| コード長 | 553 bytes |
| 記録 | |
| コンパイル時間 | 1,356 ms |
| コンパイル使用メモリ | 84,484 KB |
| 実行使用メモリ | 67,640 KB |
| 最終ジャッジ日時 | 2026-08-24 15:21:41 |
| 合計ジャッジ時間 | 13,507 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 33 |
ソースコード
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
long A = sc.nextLong();
long gcd = 0;
StringBuilder ans = new StringBuilder();
while(--N>0){
ans.append(gcd).append('\n');
long nextA = sc.nextLong();
gcd = gcd(gcd,Math.abs(A-nextA));
}
ans.append(gcd);
System.out.println(ans.toString());
}
private static long gcd(long a,long b){
if(b==0)
return a;
long temp;
while((temp=a%b)!=0){
a = b;
b = temp;
}
return b;
}
}