結果

問題 No.164 ちっちゃくないよ!!
ユーザー 37zigen37zigen
提出日時 2020-03-18 23:39:10
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 952 bytes
コンパイル時間 3,423 ms
コンパイル使用メモリ 78,336 KB
実行使用メモリ 42,428 KB
最終ジャッジ日時 2024-05-08 02:52:37
合計ジャッジ時間 4,787 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
41,228 KB
testcase_01 AC 130 ms
41,256 KB
testcase_02 AC 129 ms
41,000 KB
testcase_03 WA -
testcase_04 AC 131 ms
41,740 KB
testcase_05 WA -
testcase_06 AC 182 ms
42,092 KB
testcase_07 AC 164 ms
41,552 KB
testcase_08 AC 178 ms
42,428 KB
testcase_09 AC 176 ms
42,308 KB
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

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();
	}
	
	double pow(double a,long n) {
		double 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/3;
		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