結果

問題 No.164 ちっちゃくないよ!!
ユーザー mayoko_mayoko_
提出日時 2015-03-12 23:30:40
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 974 bytes
コンパイル時間 2,923 ms
コンパイル使用メモリ 144,588 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 02:00:40
合計ジャッジ時間 2,324 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
const ll INF = 1000000000000000000LL;

ll get(const string& s) {
    int ma = 0;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        if ('0' <= s[i] && s[i] <= '9') {
            ma = max(ma, (int)(s[i] - '0'));
        } else {
            ma = max(ma, (int)(s[i] - 'A') + 10);
        }
    }
    ma++;
    ll cur = 1;
    ll ret = 0;
    for (int i = n-1; i >= 0; i--) {
        if ('0' <= s[i] && s[i] <= '9') {
            ret += (s[i]-'0') * cur;
        } else {
            ret += (s[i]-'A'+10) * cur;
        }
        cur *= ma;
    }
    return ret;
}

int main() {
    int N;
    cin >> N;
    ll ans = INF;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        ans = min(get(s), ans);
    }
    cout << ans << endl;
    return 0;
}
0