結果

問題 No.164 ちっちゃくないよ!!
ユーザー meshedgearmeshedgear
提出日時 2015-03-15 11:16:53
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 749 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 22,144 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 15:22:46
合計ジャッジ時間 702 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 0 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 0 ms
5,376 KB
testcase_07 AC 0 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:20:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |         scanf("%d", &n);
      |         ^~~~~~~~~~~~~~~
main.c:25:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |                 scanf("%s", str);
      |                 ^~~~~~~~~~~~~~~~

ソースコード

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