結果

問題 No.164 ちっちゃくないよ!!
ユーザー kpinkcatkpinkcat
提出日時 2023-11-03 20:16:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,279 bytes
コンパイル時間 2,225 ms
コンパイル使用メモリ 203,988 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-11-03 20:16:10
合計ジャッジ時間 2,828 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<math.h>
#include<bitset>
using ll = long long;
using namespace std;


int main(){
    ll n;
    ll mans =  numeric_limits<ll>::max();
    cin >> n;
    vector<char> v(36);
    v =  {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9','A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
                        'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
                        'U', 'V', 'W', 'X', 'Y', 'Z'};
    for (ll k = 0; k < n; k++){
        ll base = 0, maxb = 0, pow = 1;
        ll ans = 0;
        string s;
        cin >> s;
        for (ll i = 0; i < s.size(); i++) {
            for (ll j = 0; j < 36; j++){
                if (s[i] == v[j]) {
                    maxb = max(maxb, j);
                    break;
                }
            }
        }
        base = ++maxb;
        for (ll i = s.size()-1; i >= 0; i--) {
            for (ll j = 0; j < 36; j++){
                if (s[i] == v[j]) {
                    ans += j*pow;
                    break;
                }
            }
            pow *= base;
        }
        mans = min(mans, ans);
    }
    cout << mans << endl;
}
0