結果

問題 No.164 ちっちゃくないよ!!
ユーザー imulanimulan
提出日時 2016-02-10 22:56:00
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 974 bytes
コンパイル時間 1,286 ms
コンパイル使用メモリ 160,440 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 22:36:11
合計ジャッジ時間 2,193 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 WA -
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>
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=101010101010101010;
  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