結果
| 問題 |
No.176 2種類の切手
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-19 23:36:03 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 575 bytes |
| コンパイル時間 | 4,459 ms |
| コンパイル使用メモリ | 251,092 KB |
| 最終ジャッジ日時 | 2025-01-31 01:43:14 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 8 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
ll a,b,c;
ll f(ll n){
ll nb = b*n;
ll d = b - a;
nb -= min(n,(nb-c)/d)*d;
return nb;
}
void solve(){
if(a>b)swap(a,b);
ll n = (c+b-1)/b;
n--;
ll l = n,r = (n+1)*100;
while(r-l>1){
ll m = (l+r)/2;
if(f(m)<f(m+1)){
r = m;
}else{
l = m;
}
}
if(f(l)<c)cout<<f(r)<<endl;
else if(f(r)<c)cout<<f(l)<<endl;
else cout<<min(f(l),f(r))<<endl;
}
signed main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
cin >> a >> b >> c;
solve();
}