結果
| 問題 | No.604 誕生日のお小遣い |
| コンテスト | |
| ユーザー |
kichirb3
|
| 提出日時 | 2018-03-16 20:49:05 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1 ms / 1,000 ms |
| + 833µs | |
| コード長 | 968 bytes |
| 記録 | |
| コンパイル時間 | 418 ms |
| コンパイル使用メモリ | 88,908 KB |
| 実行使用メモリ | 9,912 KB |
| 最終ジャッジ日時 | 2026-10-13 10:40:53 |
| 合計ジャッジ時間 | 2,115 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
// No.604 誕生日のお小遣い
// https://yukicoder.me/problems/no/604
//
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
unsigned long long int solve(unsigned long long int A, unsigned long long int B, unsigned long long int C);
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
unsigned long long A, B, C;
cin >> A >> B >> C;
unsigned long long ans = solve(A, B, C);
cout << ans << endl;
}
unsigned long long int solve(unsigned long long int A, unsigned long long int B, unsigned long long int C) {
if (A == 1) {
unsigned long long ans = C / B;
if (C % B != 0)
++ans;
return ans;
}
unsigned long long cycle_income = B + (A - 1);
unsigned long long cycle = C / cycle_income;
unsigned long long ans1 = C - (cycle_income * cycle) + A * cycle;
unsigned long long ans2 = (cycle + 1) * A;
return min(ans1, ans2);
}
kichirb3