結果

問題 No.604 誕生日のお小遣い
ユーザー ei1333333ei1333333
提出日時 2017-12-04 00:04:05
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,044 bytes
コンパイル時間 1,677 ms
コンパイル使用メモリ 199,260 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-14 01:20:37
合計ジャッジ時間 2,612 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

ostream &operator<<(ostream &os, __int128_t value)
{
  if(ostream::sentry(os)) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[64];
    char *d = end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while(tmp != 0);
    if(value < 0) {
      --d;
      *d = '-';
    }
    int len = end(buffer) - d;
    if(os.rdbuf()->sputn(d, len) != len) {
      os.setstate(ios_base::badbit);
    }
  }
  return os;
}

istream &operator>>(istream &is, __int128_t &value)
{
  string in;
  is >> in;
  value = 0;
  for(const char &c : in) {
    if('0' <= c && c <= '9') value = 10 * value + (c - '0');
  }
  if(in[0] == '-') value *= -1;
  return is;
}

int main()
{
  __int128_t A, B, C;
  cin >> A >> B >> C;

  __int128_t low = 0, high = 1LL << 62;
  while(high - low > 1) {
    auto mid = (low + high) / 2;

    auto money = mid / A * B + mid - mid / A;
    if(money >= C) high = mid;
    else low = mid;
  }

  cout << high << endl;

  return (0);
}
0