結果

問題 No.164 ちっちゃくないよ!!
ユーザー kenji_shioya
提出日時 2016-06-22 07:37:07
言語 Java
(openjdk 23)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,027 bytes
コンパイル時間 3,751 ms
コンパイル使用メモリ 78,040 KB
実行使用メモリ 54,260 KB
最終ジャッジ日時 2024-10-14 13:32:38
合計ジャッジ時間 5,066 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise110{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String[] v = new String[n];

    for(int i = 0; i < n; i++){
      v[i] = sc.next();
    }

    long decimal = Long.MAX_VALUE;
    for(int i = 0; i < v.length; i++){
      char[] num = v[i].toCharArray();
      int al = 0;
      for(int j = 0; j < num.length; j++){
        al = Math.max(changeToInt(num[j]) + 1, al);
      }
      long d = 0;
      for(int j = 0; j < num.length; j++){
        d += changeToInt(num[num.length - 1 - j]) * (long)Math.pow(al, j);
      }
      decimal = Math.min(decimal, d);
    }
    System.out.println(decimal);
  }
  private static int changeToInt(char a){
    char[] alphabet = new char[26];
    for(int i = 0; i < alphabet.length; i++){
      alphabet[i] = (char)(i + 65);
    }
    if(Character.isDigit(a)){
      return Character.getNumericValue(a);
    }else{
      return Arrays.binarySearch(alphabet, a) + 10;
    }
  }
}
0