結果

問題 No.164 ちっちゃくないよ!!
ユーザー Grenache
提出日時 2016-02-14 17:40:46
言語 Java
(openjdk 23)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 874 bytes
コンパイル時間 3,484 ms
コンパイル使用メモリ 74,872 KB
実行使用メモリ 42,108 KB
最終ジャッジ日時 2024-10-14 13:29:18
合計ジャッジ時間 6,050 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder164 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        long min = Long.MAX_VALUE;
        for (int i = 0; i < n; i++) {
        	char[] num = sc.next().toCharArray();

        	int base = 0;
        	for (char c : num) {
        		if (c >= '0' && c <= '9') {
        			base = Math.max(base, c - '0');
        		} else {
        			base = Math.max(base, c - 'A' + 10);
        		}
        	}
        	base += 1;

        	long tmp = 0;
        	for (char c : num) {
        		tmp *= base;

        		if (c >= '0' && c <= '9') {
        			tmp += c - '0';
        		} else {
        			tmp += c - 'A' + 10;
        		}
        	}

        	min = Math.min(min, tmp);
        }

        System.out.println(min);

        sc.close();
    }
}
0