結果
問題 |
No.2821 A[i] ← 2A[j] - A[i]
|
ユーザー |
|
提出日時 | 2024-04-07 00:51:59 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 475 bytes |
コンパイル時間 | 2,131 ms |
コンパイル使用メモリ | 74,700 KB |
実行使用メモリ | 71,300 KB |
最終ジャッジ日時 | 2024-07-26 20:51:04 |
合計ジャッジ時間 | 28,053 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 28 TLE * 5 |
ソースコード
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; while(--N>0){ System.out.println(gcd); long nextA = sc.nextLong(); gcd = gcd(gcd,Math.abs(A-nextA)); } System.out.println(gcd); } 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; } }