結果

問題 No.499 7進数変換
ユーザー beetbeet
提出日時 2019-03-31 13:57:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,605 bytes
コンパイル時間 1,994 ms
コンパイル使用メモリ 206,380 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 10:51:12
合計ジャッジ時間 2,919 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 1 ms
6,944 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 1 ms
6,944 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 1 ms
6,944 KB
testcase_26 AC 1 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 1 ms
6,940 KB
testcase_30 AC 1 ms
6,940 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