結果

問題 No.1350 2019-6problem
ユーザー chacoder1chacoder1
提出日時 2021-01-23 20:54:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 911 bytes
コンパイル時間 1,966 ms
コンパイル使用メモリ 200,040 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 05:17:16
合計ジャッジ時間 3,694 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 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;
  if(l+(l*a)/b-(l*a)/lm==k){
      cout<<l*a<<endl;
      return 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;
  if(l+(l*b)/a-(l*b)/lm==k){
      cout<<l*b<<endl;
      return 0;
  }
  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