結果

問題 No.1350 2019-6problem
ユーザー chacoder1chacoder1
提出日時 2021-01-23 20:44:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 764 bytes
コンパイル時間 2,209 ms
コンパイル使用メモリ 199,532 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-30 05:03:20
合計ジャッジ時間 3,449 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
signed main(){
  ll a,b,k;
  cin>>a>>b>>k;
  ll lm=lcm(a,b);
  //a列チェック
  ll l=1;
  ll r=k;
  ll m=0;
  while(r>l+1){
    m=(r+l)/2;
    //cout<<r<<" "<<l<<" "<<m<<endl;

    if(m+(m*a)/b-(m*a)/lm==k){
      cout<<m*a<<endl;
      return 0;
    }
    else if(m+(m*a)/b-(m*a)/lm>k){
      r=m;
      continue;
    }
    else{
      l=m;
      continue;
    }
  }
  //b列チェック
  l=1;
  r=k;
  while(r>l+1){
    ll m=(r+l)/2;
    if(m+(m*b)/a-(m*a)/lm==k){
      cout<<m*b<<endl;
      return 0;
    }
    else if(m+(m*b)/a-(m*b)/lm>k){
      r=m;
      continue;
    }
    else{
      l=m;
      continue;
    }
  }  
    
  
  
  return 0;
}
0