結果
問題 | No.782 マイナス進数 |
ユーザー |
|
提出日時 | 2021-04-13 23:59:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 44 ms / 2,000 ms |
コード長 | 682 bytes |
コンパイル時間 | 2,639 ms |
コンパイル使用メモリ | 210,504 KB |
最終ジャッジ日時 | 2025-01-20 17:21:13 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
ソースコード
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int T,B; cin >> T >> B; while(T--) { int n; cin >> n; if(n==0) { cout << 0 << '\n'; continue; } string res; while(1) { if(n==0) { break; } int a = n%B; n/=B; if(a < 0) { a += abs(B); n++; } res = (char)(a+'0') + res; } cout << res << '\n'; } return 0; }