結果

問題 No.442 和と積
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-11 23:42:21
言語 Java19
(openjdk 21)
結果
AC  
実行時間 130 ms / 1,000 ms
コード長 852 bytes
コンパイル時間 2,034 ms
コンパイル使用メモリ 71,856 KB
実行使用メモリ 56,160 KB
最終ジャッジ日時 2023-09-18 06:21:47
合計ジャッジ時間 5,685 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,160 KB
testcase_01 AC 124 ms
55,260 KB
testcase_02 AC 124 ms
55,968 KB
testcase_03 AC 125 ms
55,604 KB
testcase_04 AC 126 ms
55,844 KB
testcase_05 AC 124 ms
53,672 KB
testcase_06 AC 125 ms
55,536 KB
testcase_07 AC 127 ms
55,572 KB
testcase_08 AC 130 ms
55,416 KB
testcase_09 AC 124 ms
55,560 KB
testcase_10 AC 126 ms
55,528 KB
testcase_11 AC 125 ms
55,764 KB
testcase_12 AC 123 ms
55,652 KB
testcase_13 AC 126 ms
55,580 KB
testcase_14 AC 124 ms
55,844 KB
testcase_15 AC 123 ms
55,576 KB
testcase_16 AC 123 ms
55,656 KB
testcase_17 AC 124 ms
55,572 KB
testcase_18 AC 124 ms
55,520 KB
testcase_19 AC 123 ms
55,844 KB
testcase_20 AC 125 ms
55,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 y = 0;
        long m = A;
        long n = B;
        while(true){
            y = m%n;
            if(y==0){
                break;
            }
            m=n;
            n=y;
        }

        long S = (A+B)/n;
        long a = A/n;
        long x = 0;
        while(true){
            x = S%a;
            if(x==0){
                break;
            }
            S=a;
            a=x;
        }

        S = (A+B)/n;
        long b = B;
        while(true){
            x = S%b;
            if(x==0){
                break;
            }
            S=b;
            b=x;
        }
        System.out.println(n*a*b);
    }
}
0