結果

問題 No.164 ちっちゃくないよ!!
ユーザー izryt(趣味)izryt(趣味)
提出日時 2016-01-18 03:06:00
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 710 bytes
コンパイル時間 1,315 ms
コンパイル使用メモリ 145,732 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-04 16:17:31
合計ジャッジ時間 2,030 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

string V[1000];

bool cmpr(string a, string b)
{
    return a.size() < b.size();
}

long long f1(string a)
{
    int b;

    char maxc = 0;
    for (int i = 0; i < a.size(); ++i) maxc = max(maxc, a[i]);

    b = (isdigit(maxc) ? maxc - '0' + 1 : maxc - 'A' + 11);

    ll c = 1;
    ll res = 0;

    for (int i = a.size() - 1; i >= 0; --i) {
        res += (isdigit(a[i]) ? a[i] - '0' : a[i] - 'A' + 10) * c;
        c *= b;
    }

    return res;
}

int main()
{
    int N; cin >> N;

    for (int i = 0; i < N; ++i) cin >> V[i];

    ll mi = LLONG_MAX;

    for (int i = 0; i < N; ++i) mi = min(mi, f1(V[i]));

    cout << mi << endl;
}
0