結果
| 問題 | No.499 7進数変換 |
| コンテスト | |
| ユーザー |
p4mf
|
| 提出日時 | 2017-04-07 23:45:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 821 bytes |
| コンパイル時間 | 581 ms |
| コンパイル使用メモリ | 70,204 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-16 03:20:05 |
| 合計ジャッジ時間 | 1,419 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 |
ソースコード
#include <cstdio>
#include <iostream>
#include <string>
#include <limits>
#include <algorithm>
using namespace std;
#define DEBUG(X) cerr<<__LINE__<<" "<<#X<<": "<<X<<endl;
#define sci(x) int x;scanf("%d",&x);
#define scii(x, y) int x,y;scanf("%d%d",&x,&y);
template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string ret;
static numeric_limits<TypeInt> t;
TypeInt n = v;
if (t.is_signed) {
if (v < 0) n *= -1;
}
while (n >= base) {
ret += table[n%base];
n /= base;
}
ret += table[n];
if (t.is_signed) {
if (v < 0 && base == 10) ret += '-';
}
// 文字列の順番を逆にする
std::reverse(ret.begin(), ret.end());
return ret;
}
int main(){
sci(N)
cout << Itoa(N, 7) << endl;
}
p4mf