結果

問題 No.164 ちっちゃくないよ!!
ユーザー kichirb3kichirb3
提出日時 2018-03-22 21:26:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 1,156 bytes
コンパイル時間 649 ms
コンパイル使用メモリ 73,404 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-07 01:50:24
合計ジャッジ時間 1,884 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// No.164 ちっちゃくないよ!!
// https://yukicoder.me/problems/no/164
//

#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

unsigned long long int solve(vector<string> &V);


int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

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

    unsigned long long ans = solve(V);
    cout << ans << endl;
}

unsigned long long int solve(vector<string> &V) {
    unsigned long long ans = pow(2, 63);

    for (string v: V) {
        size_t idx;
        size_t l = v.size();
        for (auto i = 0; i < l; ++i) {
            if (v[i] == '0')
                v[i] = ' ';
            else
                break;
        }
        for (int base = 2; base <= 36; ++base) {
            try {
                unsigned long long t = stoull(v, &idx, base);
                if (idx == l) {
                    ans = min(ans, t);
                    break;
                }
            } catch (invalid_argument& e){
                ;
            }
        }
    }
    return ans;
}
0