結果

問題 No.164 ちっちゃくないよ!!
ユーザー TLwiegehttTLwiegehtt
提出日時 2015-07-12 02:54:36
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 938 bytes
コンパイル時間 842 ms
コンパイル使用メモリ 24,868 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-03 17:11:40
合計ジャッジ時間 1,098 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 0 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:5:15: warning: conflicting types for built-in function ‘pow’ [-Wbuiltin-declaration-mismatch]
 long long int pow(int x, int n){
               ^~~

ソースコード

diff #

#include <stdio.h>

char alphabet[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

long long int pow(int x, int n){
	int i;
	long long int sum = 1;
	for(i=0;i<n;i++){
		sum *= x;
	}
	return sum;
}

long long int convertN(char *s, int n ){
	
	int i,j;
	int len;
	long long int sum=0;
	for(len=0;s[len]!='\0';len++);
	
	for(i=0, j=len-1; i<=j;i++,j--){
		char tmp = s[i];
		s[i] = s[j];
		s[j] = tmp;
	}
	
	for(i=0;i<len;i++){
		int x;
		for(x=0;alphabet[x] != s[i];x++);
		sum = sum + (x*pow(n,i));
	}
	
	return sum;
}

int main(void){
	int i,n=0;
	long long int ans = -1;
	scanf("%d", &n);
	
	for(i=0;i<n;i++){
		int j;
		int maxAlpha=0;
		long long int tmp;
		char s[110];
		scanf("%s", s);
		
		for(j=0;s[j]!='\0';j++){
			int x;
			for(x=0;alphabet[x] != s[j];x++);
			if(maxAlpha < x){maxAlpha = x;}
		}
		
		tmp = convertN(s, maxAlpha+1 );
		
		if(ans == -1 || tmp < ans ){
			ans = tmp;
		}
	}
	
	printf("%lld\n", ans);
	
	
	return 0;
}
0