結果
問題 | No.782 マイナス進数 |
ユーザー |
![]() |
提出日時 | 2019-03-31 13:58:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 1,605 bytes |
コンパイル時間 | 2,361 ms |
コンパイル使用メモリ | 198,072 KB |
最終ジャッジ日時 | 2025-01-07 00:41:37 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
ソースコード
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} //BEGIN CUT HERE template<typename T> vector<T> convert_base(T x,T b){ vector<T> res; T t=1,k=abs(b); while(x){ res.emplace_back((x*t)%k); if(res.back()<0) res.back()+=k; x-=res.back()*t; x/=k; t*=b/k; } if(res.empty()) res.emplace_back(0); reverse(res.begin(),res.end()); return res; } //END CUT HERE //INSERT ABOVE HERE signed ABC105_C(){ long long p; cin>>p; auto ans=convert_base(p,-2LL); for(auto x:ans) cout<<x; cout<<endl; return 0; } /* verified on 2019/03/31 https://atcoder.jp/contests/abc105/tasks/abc105_c */ signed AOJ_0233(){ long long p; while(cin>>p,p){ auto ans=convert_base(p,-10LL); for(auto x:ans) cout<<x; cout<<endl; } return 0; } /* verified on 2019/03/31 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0233 */ signed YUKI_499(){ long long p; cin>>p; auto ans=convert_base(p,7LL); for(auto x:ans) cout<<x; cout<<endl; return 0; } /* verified on 2019/03/31 https://yukicoder.me/problems/no/499 */ signed YUKI_782(){ long long t,b; cin>>t>>b; while(t--){ long long p; cin>>p; auto ans=convert_base(p,b); for(auto x:ans) cout<<x; cout<<endl; } return 0; } /* verified on 2019/03/31 https://yukicoder.me/problems/no/782 */ signed main(){ //ABC105_C(); //AOJ_0233(); //YUKI_499(); YUKI_782(); return 0; }