結果

問題 No.164 ちっちゃくないよ!!
ユーザー hotpepsihotpepsi
提出日時 2015-09-15 01:25:24
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 578 bytes
コンパイル時間 585 ms
コンパイル使用メモリ 59,484 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 15:27:21
合計ジャッジ時間 940 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’:
main.cpp:14:30: warning: integer overflow in expression of type ‘long long int’ results in ‘9223372036854775807’ [-Woverflow]
   14 |         LL ans = (1LL << 63) - 1;
      |                  ~~~~~~~~~~~~^~~

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>

using namespace std;
typedef long long LL;

int main(int argc, char *argv[])
{
	string s;
	getline(cin, s);
	int N = atoi(s.c_str());
	LL ans = (1LL << 63) - 1;
	for (int i = 0; i < N; ++i) {
		getline(cin, s);
		char m = *max_element(s.begin(), s.end());
		LL x = m - '0' + 1;
		if (x > 10) {
			x = m - 'A' + 11;
		}
		LL v = 0;
		for (char c : s) {
			v *= x;
			LL a = c - '0';
			if (a > 9) {
				a = c - 'A' + 10;
			}
			v += a;
		}
		ans = min(ans, v);
	}
	cout << ans << endl;
	return 0;
}
0