結果
問題 | No.442 和と積 |
ユーザー |
![]() |
提出日時 | 2020-09-12 23:11:06 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 122 ms / 1,000 ms |
コード長 | 512 bytes |
コンパイル時間 | 4,381 ms |
コンパイル使用メモリ | 75,976 KB |
実行使用メモリ | 41,856 KB |
最終ジャッジ日時 | 2025-01-02 14:59:50 |
合計ジャッジ時間 | 8,367 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); long a = sc.nextLong(); long b = sc.nextLong(); long c = a + b; long ans = 1; long gcd1 = getGCD(c, a); ans *= gcd1; c /= gcd1; long gcd2 = getGCD(c, b); ans *= gcd2; System.out.println(ans); } static long getGCD(long x, long y) { if (x % y == 0) { return y; } else { return getGCD(y, x % y); } } }