結果
問題 |
No.442 和と積
|
ユーザー |
![]() |
提出日時 | 2020-09-10 19:55:57 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 715 bytes |
コンパイル時間 | 2,224 ms |
コンパイル使用メモリ | 74,696 KB |
実行使用メモリ | 61,164 KB |
最終ジャッジ日時 | 2024-12-23 21:00:31 |
合計ジャッジ時間 | 7,788 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 TLE * 1 |
ソースコード
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; HashMap<Long, Integer> map = new HashMap<>(); long ans = 1; for (long i = 2; i <= Math.sqrt(c); i++) { while (c % i == 0) { if (a % i == 0) { ans *= i; a /= i; } else if (b % i == 0) { ans *= i; b /= i; } c /= i; } } if (a % c == 0) { ans *= c; } else if (b % c == 0) { ans += c; } System.out.println(ans); } }