結果

問題 No.164 ちっちゃくないよ!!
ユーザー kapo
提出日時 2016-05-23 14:46:48
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 712 bytes
コンパイル時間 564 ms
コンパイル使用メモリ 61,412 KB
実行使用メモリ 6,816 KB
最終ジャッジ日時 2024-10-14 13:31:52
合計ジャッジ時間 1,024 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:25:15: warning: integer constant is so large that it is unsigned
   25 |         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