結果
| 問題 |
No.782 マイナス進数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-05-05 11:54:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 832 bytes |
| コンパイル時間 | 1,744 ms |
| コンパイル使用メモリ | 170,496 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-24 15:16:27 |
| 合計ジャッジ時間 | 3,405 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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);
long long T, B;
cin >> T >> B;
long long b = -B;
vector<long long> Ns(T, 0);
for (auto & n: Ns) cin >> n;
for (auto n : Ns){
if (n == 0){
cout << "0/n";
continue;
}
vector<long long> 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;
}