結果
| 問題 |
No.604 誕生日のお小遣い
|
| コンテスト | |
| ユーザー |
kichirb3
|
| 提出日時 | 2018-03-16 20:49:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 968 bytes |
| コンパイル時間 | 726 ms |
| コンパイル使用メモリ | 69,744 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-21 19:23:37 |
| 合計ジャッジ時間 | 1,269 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
// 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