結果
| 問題 |
No.915 Plus Or Multiple Operation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-25 21:53:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 786 bytes |
| コンパイル時間 | 1,483 ms |
| コンパイル使用メモリ | 167,696 KB |
| 実行使用メモリ | 16,968 KB |
| 最終ジャッジ日時 | 2024-11-07 03:27:15 |
| 合計ジャッジ時間 | 7,844 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define rep(i, n) FOR(i, 0, n)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll query(int a, int b, int c){
ll ans = 0;
while(a){
if(a%c){
ans += b;
a -= a%c;
}else if(a < 2*c-1){
ans += b;
a -= c;
}else{
ans += b;
a /= c;
}
}
return ans;
}
int main(void){
int q;
cin >> q;
rep(i, q){
int a, b, c;
cin >> a >> b >> c;
co(query(a, b, c));
}
return 0;
}