結果

問題 No.164 ちっちゃくないよ!!
ユーザー not_522not_522
提出日時 2015-07-28 10:18:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 976 bytes
コンパイル時間 1,300 ms
コンパイル使用メモリ 159,200 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 15:25:53
合計ジャッジ時間 1,879 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

template<typename T> inline T toInteger(const string&);

template<> inline int toInteger<int>(const string& s) {
  return stoi(s);
}

template<> inline long toInteger<long>(const string& s) {
  return stol(s);
}

template<> inline long long toInteger<long long>(const string& s) {
  return stoll(s);
}

template<typename T = long long> inline T toInteger(const string& s, int n) {
  T res = 0;
  for (char c : s) {
    if (isdigit(c)) res = res * n + c - '0';
    else if (isalpha(c)) res = res * n + tolower(c) - 'a' + 10;
  }
  return s[0] == '-' ? -res : res;
}

int main() {
  int n;
  cin >> n;
  long long res = numeric_limits<long long>::max();
  for (int i = 0; i < n; ++i) {
    string v;
    cin >> v;
    int mx = 0;
    for (char c : v) {
      if (isdigit(c)) mx = max(mx, c - '0' + 1);
      else if (isalpha(c)) mx = max(mx, c - 'A' + 11);
    }
    res = min(res, toInteger(v, mx));
  }
  cout << res << endl;
}
0