結果
問題 |
No.782 マイナス進数
|
ユーザー |
|
提出日時 | 2020-04-13 13:52:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 41 ms / 2,000 ms |
コード長 | 746 bytes |
コンパイル時間 | 1,564 ms |
コンパイル使用メモリ | 169,100 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 19:48:54 |
合計ジャッジ時間 | 3,482 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; using ll = long long ; using P = pair<int,int> ; const ll INF = 1e18; const int MOD = 1000000007; int b; vector<int> solve(int n){ vector<int> res; while(n != 0){ int d = n / b; int m = n % b; if(m < 0){ d ++; m -= b; } res.push_back(m); n = d; } reverse(res.begin(),res.end()); return res; } int main(){ int t; cin >> t >> b; rep(_,t){ int n; cin >> n; if(n==0){ cout << 0 << endl; continue; } vector<int> a = solve(n); rep(i,a.size()) cout << a[i] ; cout << endl; } return 0; }