結果

問題 No.915 Plus Or Multiple Operation
ユーザー kibunakibuna
提出日時 2019-10-25 21:41:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,067 bytes
コンパイル時間 1,732 ms
コンパイル使用メモリ 164,092 KB
実行使用メモリ 13,952 KB
最終ジャッジ日時 2024-04-24 18:34:05
合計ジャッジ時間 8,364 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int q;
    cin >> q;
    vl a(q), b(q), c(q);
    for (int i = 0; i < q; ++i) {
        cin >> a[i] >> b[i] >> c[i];
    }
    for (int i = 0; i < q; ++i) {
        ll ret = 0;
        while (a[i] > 0) {
            if (a[i] % c[i] != 0)
                ret++;
            a[i] /= c[i];
            ret++;
        }
        cout << (ret - 1LL) * b[i] << "\n";
    }
    return 0;
}
0