結果

問題 No.1423 Triangle of Multiples
ユーザー tentententen
提出日時 2021-03-15 09:44:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 476 ms / 2,000 ms
コード長 976 bytes
コンパイル時間 2,223 ms
コンパイル使用メモリ 78,084 KB
実行使用メモリ 49,044 KB
最終ジャッジ日時 2024-04-24 14:29:53
合計ジャッジ時間 4,641 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
36,676 KB
testcase_01 AC 52 ms
36,432 KB
testcase_02 AC 308 ms
49,044 KB
testcase_03 AC 461 ms
45,472 KB
testcase_04 AC 476 ms
44,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
       }
   }
}

0