結果

問題 No.442 和と積
ユーザー ouoz1Vouoz1V
提出日時 2016-11-11 23:40:17
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 519 bytes
コンパイル時間 408 ms
コンパイル使用メモリ 53,972 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-05-04 03:17:33
合計ジャッジ時間 2,852 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
using namespace std;

unsigned long long int gcd(unsigned long long int a,unsigned long long int b){
    while(a!=b){
        if(a>b) a-=b;
        else b-=a;
    }
    return a;
}

int main(){
    unsigned long long int a,b;
    unsigned long long int x;
    cin>>a>>b;
    unsigned long long int aplsb,amltb;
    if(a==1||b==1){
        cout<<1<<endl;
        return 0;
    }
    x=gcd(a,b);
    aplsb=(a+b)/x;
    amltb=a/x*b;
    cout<<x*gcd(aplsb,amltb)<<endl;

    return 0;
}
0