結果

問題 No.1350 2019-6problem
ユーザー zuminzumin
提出日時 2021-02-25 00:17:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 880 bytes
コンパイル時間 499 ms
コンパイル使用メモリ 64,256 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-25 05:43:54
合計ジャッジ時間 4,548 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,696 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 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 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;
using ll=long long;

ll gcd(ll m,ll n){
    if(n==0) return m;
    return gcd(n,m%n);
}
ll lcm(ll x,ll y){
    return x*y/gcd(x,y);
}

int main(){
    ll a,b,c,k;
    cin>>a>>b>>k;
    c=lcm(a,b);

    ll oka=k;
    ll nga=1;
    while(oka-nga>1){
        ll cen=(oka+nga)/2;
        ll acen=a*cen;
        ll plc=cen+acen/b-acen/c;
        if(plc>=k){
            oka=cen;
            if(plc==k){
                cout<<acen<<endl;
                return 0;
            }
        }
        else nga=cen;
    }
    ll okb=k;
    ll ngb=1;
    while(okb-ngb>1){
        ll cen=(okb+ngb)/2;
        ll bcen=b*cen;
        ll plc=cen+bcen/a-bcen/c;
        if(plc>=k){
            okb=cen;
            if(plc==k){
                cout<<bcen<<endl;
                return 0;
            }
        }
        else nga=cen;
    }

    return 0;
}
0