結果

問題 No.164 ちっちゃくないよ!!
ユーザー 37zigen37zigen
提出日時 2020-03-18 23:46:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 944 bytes
コンパイル時間 2,035 ms
コンパイル使用メモリ 74,840 KB
実行使用メモリ 56,364 KB
最終ジャッジ日時 2023-08-20 20:26:31
合計ジャッジ時間 3,655 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
55,576 KB
testcase_01 AC 102 ms
56,116 KB
testcase_02 AC 100 ms
55,772 KB
testcase_03 AC 101 ms
56,236 KB
testcase_04 AC 105 ms
55,300 KB
testcase_05 AC 145 ms
56,364 KB
testcase_06 AC 146 ms
56,200 KB
testcase_07 AC 137 ms
55,988 KB
testcase_08 AC 144 ms
56,012 KB
testcase_09 AC 145 ms
56,336 KB
testcase_10 AC 105 ms
55,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	long pow(long a,long n) {
		long ret=1;
		for(;n>0;n/=2,a*=a)if(n%2==1)ret*=a;
		return ret;
	}
	
	long g(char c) {
		if((int)(c-'0')>=0&&(int)(c-'0')<=9)return (int)(c-'0');
		else return (int)(c-'A'+10);

	}
	
	long f(char[] cs,long base) {
		long ret=0;
		for(int i=0;i<cs.length;++i) {
			ret+=g(cs[i])*pow(base,cs.length-1-i);
		}
		return ret;
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextInt();
		long ans=Long.MAX_VALUE;
		for(int i=0;i<n;++i) {
			char[] cs=sc.next().toCharArray();
			long base=0;
			for(char c:cs) {
				base=Math.max(base, g(c)+1);
			}
			ans=Math.min(ans, f(cs,base));
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
0