結果

問題 No.164 ちっちゃくないよ!!
ユーザー imulanimulan
提出日時 2016-02-10 22:57:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 975 bytes
コンパイル時間 1,381 ms
コンパイル使用メモリ 158,204 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 14:21:52
合計ジャッジ時間 1,964 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,248 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;

typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int ch(char c){
  if('0'<=c && c<='9') return c-'0';
  else return c-'A'+10;
}

int main(int argc, char const *argv[]) {
  int i,j;

  int n;
  cin >>n;

  ll ans=9010101010101010101;
  for(int q=0; q<n; ++q){
    string v;
    cin >>v;

    //まずは何進法までとることが許されるかを調べる
    int m=0;
    rep(i,v.size()){
      if('0'<=v[i] && v[i]<='9'){//数字の時
        m=max(m,v[i]-'0'+1);
      }
      else{//アルファベットの時
        m=max(m,v[i]-'A'+11);
      }
    }

    //m進法を試す
    ll t=0;
    ll mul=1;
    for(j=v.size()-1; j>=0; --j){
      t+=ch(v[j])*mul;
      mul*=m;
    }
    ans=min(ans,t);

  }
  std::cout << ans << std::endl;
  return 0;
}
0