結果

問題 No.604 誕生日のお小遣い
ユーザー @abcde@abcde
提出日時 2019-06-02 14:37:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,131 bytes
コンパイル時間 1,414 ms
コンパイル使用メモリ 162,204 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-14 01:35:25
合計ジャッジ時間 2,116 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 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,384 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 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;
using LL = long long;

int main() {
    
    // 1. 入力情報取得.
    LL A, B, C;
    scanf("%llu %llu %llu", &A, &B, &C);

    // 2. 年齢を計算.
    // ex.
    // 4 3 15
    // 1サイクル: (4 - 1) + 3 = 6円 (※4年で, 6円増加)
    // 15 / 6 = 2サイクル (※8年経過)
    // 15 % 6 = 3 (余り) -> 9年目以降で, 3円以上増加する必要がある.
    // -> 9年目: +1円, 10年目: +1円, 11年目: +1円
    // -> 11年(合計: 15円 >= 15円)かかることが分かる.
    // 
    // 4 3 16
    // 1サイクル: (4 - 1) + 3 = 6円 (※4年で, 6円増加)
    // 16 / 6 = 2サイクル (※8年経過)
    // 16 % 6 = 4 (余り) -> 9年目以降で, 4円以上増加する必要がある.
    // -> 9年目: +1円, 10年目: +1円, 11年目: +1円, 12年目: +3円
    // -> 12年(合計: 18円 >= 16円)かかることが分かる.
    LL cycle = (A - 1) + B;
    LL q = C / cycle, r = C % cycle;
    LL ans = A * q;
    if(r <= A - 1) ans += r;
    else           ans += A;
    
    // 3. 出力.
    printf("%llu\n", ans);
    return 0;
    
}
0