結果

問題 No.499 7進数変換
ユーザー @abcde@abcde
提出日時 2019-02-23 10:19:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 980 bytes
コンパイル時間 2,705 ms
コンパイル使用メモリ 150,596 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-19 06:41:16
合計ジャッジ時間 3,678 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main() {
    
    // 1. 入力情報取得.
    LL N;
    cin >> N;
    
    // 2. 7進数に変換.
    // 2-1. N が 0 なら終了.
    if(N == 0){
        cout << 0 << endl;
        return 0;
    }
    
    // 2-2. N が 0 より大きい場合.
    // -> N を ひたすら 7 で割っていく.
    map<LL, LL> ans;
    while(N){
        LL q = N / 7;
        LL r = N % 7;
        ans[q] = r;
        N /= 7;
    }
    // for(auto &p : ans) cout << p.first << " " << p.second << endl;
    // [入力例]
    // 1000000000
    // 
    // [出力例(debug版)]
    // 0 3
    // 3 3
    // 24 5
    // 173 3
    // 1214 1
    // 8499 6
    // 59499 0
    // 416493 0
    // 2915451 6
    // 20408163 1
    // 142857142 6
    // -> 上から順に余りを取ってきて, 33531600616 を抽出できた.

    // 3. 出力.
    for(auto &p : ans) cout << p.second;
    cout << endl;
    return 0;
    
}
0