結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
55,924 KB
testcase_01 AC 102 ms
56,164 KB
testcase_02 AC 101 ms
55,812 KB
testcase_03 AC 99 ms
55,624 KB
testcase_04 AC 101 ms
55,580 KB
testcase_05 WA -
testcase_06 AC 145 ms
56,052 KB
testcase_07 AC 138 ms
56,200 KB
testcase_08 AC 145 ms
56,412 KB
testcase_09 AC 144 ms
56,172 KB
testcase_10 AC 106 ms
56,032 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/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