結果

問題 No.164 ちっちゃくないよ!!
ユーザー SSRSSSRS
提出日時 2020-11-18 07:39:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 654 bytes
コンパイル時間 552 ms
コンパイル使用メモリ 71,168 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 14:50:11
合計ジャッジ時間 1,154 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
using namespace std;
const long long INF = 5000000000000000000;
int main(){
	int N;
	cin >> N;
	vector<string> V(N);
	for (int i = 0; i < N; i++){
		cin >> V[i];
	}
	long long ans = INF;
	for (int i = 0; i < N; i++){
		int L = V[i].size();
		vector<int> d(L);
		for (int j = 0; j < L; j++){
			if (isdigit(V[i][j])){
				d[j] = V[i][j] - '0';
			} else {
				d[j] = V[i][j] - 'A' + 10;
			}
		}
		int b = 2;
		for (int j = 0; j < L; j++){
			b = max(b, d[j] + 1);
		}
		long long num = 0;
		for (int j = 0; j < L; j++){
			num = num * b + d[j];
		}
		ans = min(ans, num);
	}
	cout << ans << endl;
}
0