結果

問題 No.782 マイナス進数
ユーザー beetbeet
提出日時 2019-03-31 13:58:04
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 1,605 bytes
コンパイル時間 2,036 ms
コンパイル使用メモリ 203,032 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-13 18:12:52
合計ジャッジ時間 5,214 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 23 ms
4,380 KB
testcase_03 AC 24 ms
4,384 KB
testcase_04 AC 26 ms
4,380 KB
testcase_05 AC 22 ms
4,380 KB
testcase_06 AC 23 ms
4,376 KB
testcase_07 AC 31 ms
4,376 KB
testcase_08 AC 24 ms
4,380 KB
testcase_09 AC 23 ms
4,376 KB
testcase_10 AC 22 ms
4,376 KB
testcase_11 AC 31 ms
4,376 KB
testcase_12 AC 29 ms
4,376 KB
testcase_13 AC 47 ms
4,380 KB
testcase_14 AC 29 ms
4,380 KB
testcase_15 AC 31 ms
4,376 KB
testcase_16 AC 29 ms
4,376 KB
testcase_17 AC 38 ms
4,380 KB
testcase_18 AC 29 ms
4,384 KB
testcase_19 AC 35 ms
4,376 KB
testcase_20 AC 29 ms
4,376 KB
testcase_21 AC 37 ms
4,380 KB
testcase_22 AC 30 ms
4,376 KB
testcase_23 AC 28 ms
4,376 KB
testcase_24 AC 47 ms
4,380 KB
testcase_25 AC 29 ms
4,376 KB
testcase_26 AC 33 ms
4,380 KB
testcase_27 AC 32 ms
4,380 KB
testcase_28 AC 29 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0