結果
問題 | No.782 マイナス進数 |
ユーザー |
![]() |
提出日時 | 2020-06-13 21:02:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 595 bytes |
コンパイル時間 | 1,107 ms |
コンパイル使用メモリ | 74,152 KB |
最終ジャッジ日時 | 2025-01-11 03:59:56 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
ソースコード
#include <iostream> #include <stack> using namespace std; void ins() {} template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);} #define rep(i,n) for(int i=0,_i=(n);i<_i;++i) int main() { int T, B; ins(T, B); stack<int> st; rep(i, T) { int a; cin >> a; if (a == 0) { cout << 0 << endl; continue; } while (a != 0) { int r = a % (-B); if (r < 0) r -= B; st.push(r); a -= r; a /= B; } while (!st.empty()) { cout << st.top(); st.pop(); } cout << endl; } return 0; }