結果

問題 No.164 ちっちゃくないよ!!
ユーザー meshedgearmeshedgear
提出日時 2015-03-15 11:16:53
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 749 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 24,532 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-03 17:08:12
合計ジャッジ時間 863 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <string.h>

int isnum(char c){
	if(c >= '0' && c <= '9') return 1;
	else return 0;
}
long long int exchange(char* str, int r){
	long long int res = 0, weight = 1;
	int i;
	for(i = strlen(str)-1; 0 <= i; i--){
		res += isnum(str[i]) ? (str[i]-'0')*weight : (str[i]-'A'+10)*weight;
		weight*=r;
	}
	return res;
}
int main(void) {
	int n, i;
	long long int min = -1;
	scanf("%d", &n);
	for(i = 0; n > i; i++){
		char str[13];
		int c, max = -1;
		long long int buf;
		scanf("%s", str);
		for(c = 0; strlen(str) > c; c++){
			if(max < str[c]) max = str[c];
		}
		if(isnum(max)) max = max-'0';
		else max = max-'A'+10;
		buf = exchange(str, max+1);
		if(min == -1 || buf < min) min = buf;
	}
	printf("%lld", min);
	return 0;
}
0