結果

問題 No.176 2種類の切手
ユーザー koyoprokoyopro
提出日時 2015-10-11 13:41:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 707 bytes
コンパイル時間 1,266 ms
コンパイル使用メモリ 158,180 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 22:17:26
合計ジャッジ時間 2,142 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define int long long
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
int gcd(int a, int b) { if (!b) return a; return gcd(b, a%b); }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int A, B, T;
signed main()
{
    cin >> A >> B >> T;
    int maxb = (T + B - 1) / B;
    int minC = 1e10;
    int l = A / gcd(A, B);
    int k = 0;
    RREP(i,maxb+1) {
        int cost = i * B;
        int remain = T - cost;
        int numa = (remain + A - 1) / A;
        cost += numa * A;
        minC = min(minC, cost);
        if (minC == T) break;
        if (k++ > l) break;
    }
    cout << minC << endl;
    return 0;
}
0