結果
| 問題 |
No.782 マイナス進数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-05-05 11:50:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 728 bytes |
| コンパイル時間 | 1,745 ms |
| コンパイル使用メモリ | 171,492 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-24 14:21:03 |
| 合計ジャッジ時間 | 3,917 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 WA * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int T, B;
cin >> T >> B;
int b = -B;
vector<int> Ns(T, 0);
for (auto & n: Ns) cin >> n;
for (auto n : Ns){
vector<int> ans;
int sign = 1;
while (n > 0){
if (sign == 1){
ans.push_back(n % b);
n /= b;
sign = -1;
}else{
int tmp = (b - (n % b)) % b;
ans.push_back(tmp);
n = (n + tmp)/b;
sign = 1;
}
}
for (auto it = ans.rbegin(); it != ans.rend(); ++it) cout << *it;
cout << '\n';
}
return 0;
}