結果

問題 No.164 ちっちゃくないよ!!
ユーザー jp_stejp_ste
提出日時 2015-03-16 07:18:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 728 bytes
コンパイル時間 2,344 ms
コンパイル使用メモリ 76,656 KB
実行使用メモリ 42,088 KB
最終ジャッジ日時 2024-04-21 15:22:51
合計ジャッジ時間 3,998 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
39,996 KB
testcase_01 AC 114 ms
41,388 KB
testcase_02 AC 100 ms
40,308 KB
testcase_03 AC 103 ms
40,044 KB
testcase_04 AC 114 ms
40,888 KB
testcase_05 AC 162 ms
41,944 KB
testcase_06 AC 159 ms
42,064 KB
testcase_07 AC 134 ms
41,268 KB
testcase_08 AC 155 ms
42,088 KB
testcase_09 AC 160 ms
41,892 KB
testcase_10 AC 121 ms
41,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		long ans = Long.MAX_VALUE;
				
		for(int i=0; i<n; i++) {
			String stringV = sc.next();
			Long decimalV = Long.parseLong(stringV, getMinRadix(stringV));
			ans = Math.min(decimalV, ans);
		}
		System.out.println(ans);
	}
	
	static int getMinRadix(String str) {
		int ret = 0;
		for(int i=0; i<str.length(); i++) {
			ret = Math.max(str.charAt(i), ret);
		}
		
		if(ret >= '0' && ret <= '9') {
			return ret - '0' + 1;
			
		} else if(ret >= 'A' && ret <= 'Z') {
			return ret - 'A' + 10 + 1;
		
		} else {
			throw new IllegalArgumentException("ret:"+ret);
		}	
	}
}
0