結果

問題 No.604 誕生日のお小遣い
ユーザー 👑 obakyanobakyan
提出日時 2019-04-30 12:32:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 768 bytes
コンパイル時間 560 ms
コンパイル使用メモリ 71,852 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 14:38:52
合計ジャッジ時間 1,379 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cstddef>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iostream>
#include <iomanip>
#define L64 long long
#define MOD (1000000007LL)

bool checkLt(L64 age, L64 a, L64 b, L64 c)
{
  L64 z = age / a;
  //L64 x = z * b + age - z;
  //return x < c;
  //z * b < c - age + z
  if((c - age + z) % b == 0){
    return z < (c - age + z) / b;
  } else {
    return z <= (c - age + z) / b;
  }
}

int main(void)
{
  L64 a, b, c;
  std::cin >> a >> b >> c;
  L64 min, max;
  min = 0; max = c;
  while(1LL < max - min){
    L64 mid = (min + max) / 2LL;
    bool ret = checkLt(mid, a, b, c);
    if(ret){
      min = mid;
    } else {
      max = mid;
    }
  }
  std::cout << max << std::endl;
}
0