結果

問題 No.164 ちっちゃくないよ!!
ユーザー kapokapo
提出日時 2016-05-23 14:46:48
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 712 bytes
コンパイル時間 1,032 ms
コンパイル使用メモリ 60,092 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-04 16:21:28
合計ジャッジ時間 1,226 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:25:8: warning: integer constant is so large that it is unsigned
  ans = 18446744073709551614;
        ^~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <string>
#include <cmath>

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ull unsigned long long
using namespace std;

// 0=48 9=57 A=65 Z=90

int ctoi(char c)
{
	if(c <= 58) return (int)c-48;
	else return (int)c-55; // -65+10
}

int main(void)
{
	int n, num, dig;
	ull sum, ans;
	string s, a;
	char c, mc = 0;
	cin >> n;

	ans = 18446744073709551614;
	rep(i, 0, n) {
		cin >> s;
		mc = 0;
		rep(i, 0, s.size()) {
			c = s[i];
			if (c > mc) mc = c;
		}
		dig = ctoi(mc + 1);

		sum = 0;
		rep(i, 0, s.size()) {
			c = s[s.size() - 1 - i];
			num = ctoi(c);
			if(n) sum += num * (ull)pow(dig, i);
		}
		if(sum < ans) {
			ans = sum;
		}
	}

	printf("%llu\n",ans);
	return 0;
}
0