結果

問題 No.2087 基数の変換
ユーザー V_Melville
提出日時 2022-09-30 22:46:53
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 429 bytes
コンパイル時間 4,689 ms
コンパイル使用メモリ 319,712 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 00:31:18
合計ジャッジ時間 6,071 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/extc++.h>

using namespace std;

void convert(int m, int n) {
    stack<int> s;
    if (!m) s.push(0);
    else {
        while (m) {
            s.push(m%n);
            m /= n;
        }
    }
    while (s.size()) {
        cout << s.top();
        s.pop();
    }
    puts("");
}

int main() {
    int n, m;
    cin >> n >> m;
    
    if (n == 10) cout << m << '\n';
    else convert(m, n);
    
    return 0;
}
0