結果

問題 No.164 ちっちゃくないよ!!
コンテスト
ユーザー bal4u
提出日時 2019-04-12 21:56:13
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 677 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 294 ms
コンパイル使用メモリ 38,400 KB
最終ジャッジ日時 2026-02-22 02:55:13
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// yukicoder: No.164 ちっちゃくないよ
// 2019.4.12 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int N;
char v[20];

long long calc(char *s)
{
	int a, min;
	long long ans;
	char *p;

	min = 0, p = s;
	while (*p) {
		if (isdigit(*p)) a = *p - '0';
		else a = *p - 'A' + 10;
		if (a > min) min = a;
		p++;
	}
	min++;
	ans = 0, p = s;
	while (*p) {
		if (isdigit(*p)) a = *p - '0';
		else a = *p - 'A' + 10;
		ans = ans * min + a;
		p++;
	}
	return ans;
}

int main()
{
	int i;
	long long a, ans;

	scanf("%d", &N);
	ans = 0x7fffffffffffffff;
	for (i = 0; i < N; i++) {
		scanf("%s", v);
		if ((a = calc(v)) < ans) ans = a;
	}
	printf("%lld\n", ans);
}
0