結果

問題 No.164 ちっちゃくないよ!!
ユーザー 古寺いろは古寺いろは
提出日時 2015-03-23 16:11:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 427 ms
コンパイル使用メモリ 58,852 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-03 17:08:36
合計ジャッジ時間 1,077 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	int N;
	cin >> N;
	
	long long ans = (long long)5e18;
	for (int i = 0; i < N; i++)
	{
		string s;
		cin >> s;

		int d = 2;
		for (int j = 0; j < s.size(); j++)
		{
			if (s[j] >= '0' && s[j] <= '9') d = max(d, s[j] - '0' + 1);
			else d = max(d, s[j] - 'A' + 11);
		}


		long long temp = 0;
		long long mul = 1;
		for (int j = s.size() - 1; j >= 0; j--)
		{
			int num;
			if (s[j] >= '0' && s[j] <= '9') num = s[j] - '0';
			else num = s[j] - 'A' + 10;

			temp += num * mul;
			mul *= d;
		}

		ans = min(ans, temp);
	}

	cout << ans;
}
0