結果
問題 | No.782 マイナス進数 |
ユーザー |
|
提出日時 | 2019-01-13 18:04:07 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 348 bytes |
コンパイル時間 | 1,475 ms |
コンパイル使用メモリ | 159,972 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-26 00:37:33 |
合計ジャッジ時間 | 3,351 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int a,b,k[10005]; cin>>a>>b; for(int i=0;i<a;++i){ cin>>k[i]; if(k[i]==0){ cout<<0<<endl; continue; } string ans=""; while(k[i]){ int mon=k[i]%b,mmon=k[i]/b; if(mon<0){mon-=b;++mmon;} ans+=to_string(mon); k[i]=mmon; } reverse(ans.begin(),ans.end()); cout<<ans<<endl; } }