結果

問題 No.164 ちっちゃくないよ!!
コンテスト
ユーザー not_522
提出日時 2015-07-28 10:18:59
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 573µs
コード長 976 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 867 ms
コンパイル使用メモリ 176,204 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-09-15 18:35:22
合計ジャッジ時間 1,869 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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