結果

問題 No.164 ちっちゃくないよ!!
ユーザー @abcde@abcde
提出日時 2019-06-03 21:31:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,286 bytes
コンパイル時間 1,793 ms
コンパイル使用メモリ 175,080 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 23:29:26
合計ジャッジ時間 2,992 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    
    // 1. 入力情報取得.
    int N;
    cin >> N;
    string BASE = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    map<char, LL> ma;
    for(int i = 0; i < BASE.size(); i++){
        char c = BASE[i];
        if(i < 10) ma[c] = c - '0' + 1;
        else       ma[c] = c - 'A' + 11;
    }
    // for(auto &p : ma) cout << p.first << " " << p.second << endl;
    
    // 2. 与えられた整数で, 最小の値を計算.
    // 1000000000000(36進数) = 4738381338321616896
    // -> 1e19 あれば十分と思う.
    LL ans = 1e19;
    for(int i = 0; i < N; i++){
        string v;
        cin >> v;
        // 各整数V[i] で, 各桁の値を見て, p進数を取得.
        LL p = 0;
        for(int j = 0; j < v.size(); j++){
            char c = v[j];
            p = max(p, ma[c]);
        }
        
        // p進数として, V[i] を 10進数に変換.
        LL v10 = 0, coef = 1;
        for(int j = v.size() - 1; j >= 0; j--){
            char c = v[j];
            v10 += (ma[c] - 1) * coef;
            coef *= p;
        }
        
        // ans の 更新.
        ans = min(ans, v10);
    }
    
    // 3. 出力.
    cout << ans << endl;
    return 0;
    
}
0