結果

問題 No.176 2種類の切手
ユーザー koba-e964
提出日時 2017-01-06 13:49:46
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 372 bytes
コンパイル時間 419 ms
コンパイル使用メモリ 57,276 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-17 19:58:59
合計ジャッジ時間 1,256 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>

using namespace std;
typedef long long int ll;

int main(void){
  ll a, b, t;
  cin >> a >> b >> t;
  ll mi = (t + a - 1) / a * a;
  for (ll x = 0; x < a * b && x < t + b; x += b) {
    ll rem = t - x;
    ll tmp = x;
    if (rem > 0) {
      tmp += (rem + a - 1) / a * a;
    }
    mi = min(mi, tmp);
  }
  cout << mi << endl;
}
0