結果
| 問題 | No.499 7進数変換 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-16 09:20:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 681 bytes |
| コンパイル時間 | 2,314 ms |
| コンパイル使用メモリ | 196,032 KB |
| 最終ジャッジ日時 | 2025-01-10 12:21:32 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
std::vector<int64_t> convert_base_to(int64_t val, int64_t base){
if(val == 0) return {0};
std::vector<int64_t> ret;
while(val){
if(val < base){
ret.push_back(val);
break;
}
ret.push_back(val % base);
val /= base;
}
return ret;
}
int64_t convert_base_from(const std::vector<int64_t> &val, int64_t base){
int64_t ret = 0;
for(auto it = val.rbegin(); it != val.rend(); ++it){
(ret *= base) += *it;
}
return ret;
}
int main(){
int N; std::cin >> N;
auto res = convert_base_to(N, 7);
std::reverse(res.begin(), res.end());
for(auto x : res) std::cout << x;
std::cout << "\n";
return 0;
}