結果

問題 No.915 Plus Or Multiple Operation
ユーザー tekihei2317tekihei2317
提出日時 2019-10-28 19:45:47
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 633 bytes
コンパイル時間 1,462 ms
コンパイル使用メモリ 163,116 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-07 00:34:45
合計ジャッジ時間 2,197 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int solve()
{
    int a,b,c; cin>>a>>b>>c;
    if(c==1) return -1;
    int len=0,cnt=0;
    for(;a>0;a/=c){
        int d=a%c;
        len++;
        if(d==0) cnt++;
    }        
    int res=(2*len-1)-cnt;
    res*=b;
    return res;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int Q; cin>>Q;
    while(Q--){
        cout<<solve()<<endl;
    }
    return 0;
}
0