結果

問題 No.164 ちっちゃくないよ!!
ユーザー h_nosonh_noson
提出日時 2016-03-14 12:56:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,048 bytes
コンパイル時間 2,152 ms
コンパイル使用メモリ 62,312 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-04 16:19:43
合計ジャッジ時間 1,861 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define RREP(i,s,e) for (i = e-1; i >= s; i--)
#define rrep(i,n) RREP(i,0,n)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e8

typedef long long ll;

ll power(ll a, int n) {
    if (n == 0)
        return 1;
    else
        return a * power(a,n-1);
}

int main() {
    int i, j, n;
    ll ans;
    cin >> n;
    ans = power(36,12);
    rep (i,n) {
        int base, w;
        ll x, v;
        string s;
        cin >> s;
        w = s.size();
        base = 0;
        for (char c : s) {
            if (isdigit(c))
                base = max(base,c - '0');
            else
                base = max(base,c - 'A' + 10);
        }
        base++;
        v = 0;
        rep (j,w){
            if (isdigit(s[w-j-1]))
                x = s[w-j-1] - '0';
            else
                x = s[w-j-1] - 'A' + 10;
            v += power(base,j)*x;
        }
        ans = min(ans,v);
    }
    cout << ans << endl;
    return 0;
}
0