結果
| 問題 |
No.782 マイナス進数
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2019-01-11 21:35:20 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 46 ms / 2,000 ms |
| コード長 | 770 bytes |
| コンパイル時間 | 1,367 ms |
| コンパイル使用メモリ | 97,464 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 04:39:16 |
| 合計ジャッジ時間 | 3,273 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 36 |
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main()
{
int t, b; cin>>t>>b;
for(int i=0; i<t; i++){
int n; cin>>n;
if(n==0){
cout<<0<<endl;
continue;
}
vector<int> ans;
int c=0;
while(n!=0){
int r;
if(n<0) r=(-b-(-n)%(-b))%(-b);
else r=n%(-b);
ans.push_back(r);
n-=r;
n/=(-b);
n=-n;
}
reverse(ans.begin(), ans.end());
for(auto x:ans) cout<<x;
cout<<endl;
}
return 0;
}
chocorusk