結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
56,008 KB
testcase_01 AC 102 ms
55,812 KB
testcase_02 AC 101 ms
55,600 KB
testcase_03 AC 101 ms
56,144 KB
testcase_04 AC 102 ms
55,536 KB
testcase_05 WA -
testcase_06 AC 149 ms
56,204 KB
testcase_07 AC 141 ms
56,192 KB
testcase_08 AC 146 ms
56,304 KB
testcase_09 AC 146 ms
56,384 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();
	}
	
	long pow(double 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/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