結果
問題 | No.782 マイナス進数 |
ユーザー |
![]() |
提出日時 | 2019-01-11 22:04:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 821 bytes |
コンパイル時間 | 2,178 ms |
コンパイル使用メモリ | 195,424 KB |
最終ジャッジ日時 | 2025-01-06 20:19:55 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 WA * 9 |
ソースコード
#include <bits/stdc++.h> #define rep(i, a, n) for(int i = a; i < n; i++) #define repr(i, a, b) for(int i = a; i >= b; i--) #define int long long #define all(a) a.begin(), a.end() #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) using namespace std; typedef pair<int, int> P; const int mod = 1000000007; const int INF = 1e18; signed main(){ ios::sync_with_stdio(false); cin.tie(0); int t, b; cin >> t >> b; while(t--){ int n; cin >> n; string s = ""; int v = 1; while(n){ int tmp = n % abs(b); if(v == -1) tmp = (abs(b) - tmp) % abs(b); s += '0' + tmp; n -= v * tmp; n /= abs(b); v *= -1; } reverse(s.begin(), s.end()); cout << s << endl; } }