結果
問題 | No.1423 Triangle of Multiples |
ユーザー | tenten |
提出日時 | 2021-03-15 09:44:00 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 321 ms / 2,000 ms |
コード長 | 976 bytes |
コンパイル時間 | 2,378 ms |
コンパイル使用メモリ | 77,480 KB |
実行使用メモリ | 48,752 KB |
最終ジャッジ日時 | 2024-11-06 22:53:34 |
合計ジャッジ時間 | 4,303 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 |
ソースコード
import java.util.*; import java.io.*; public class Main { public static void main (String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); StringBuilder sb = new StringBuilder(); for (int i = 0; i < t; i++) { String[] line = br.readLine().split(" ", 3); int a = Integer.parseInt(line[0]); int b = Integer.parseInt(line[1]); int c = Integer.parseInt(line[2]); long lcm = getLCM(a, b, c); sb.append(lcm).append(" ").append(lcm).append(" ").append(lcm).append("\n"); } System.out.print(sb); } static long getLCM(long a, long b, long c) { return getLCM(getLCM(a, b), c); } static long getLCM(long a, long b) { return a / getGCD(a, b) * b; } static long getGCD(long a, long b) { if (a % b == 0) { return b; } else { return getGCD(b, a % b); } } }