結果

問題 No.164 ちっちゃくないよ!!
ユーザー TLwiegehttTLwiegehtt
提出日時 2015-07-12 02:54:36
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 938 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 21,888 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 15:25:50
合計ジャッジ時間 626 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 0 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 0 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 0 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:5:15: warning: conflicting types for built-in function ‘pow’; expected ‘double(double,  double)’ [-Wbuiltin-declaration-mismatch]
    5 | long long int pow(int x, int n){
      |               ^~~
main.c:2:1: note: ‘pow’ is declared in header ‘<math.h>’
    1 | #include <stdio.h>
  +++ |+#include <math.h>
    2 | 
main.c: In function ‘main’:
main.c:39:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |         scanf("%d", &n);
      |         ^~~~~~~~~~~~~~~
main.c:46:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   46 |                 scanf("%s", s);
      |                 ^~~~~~~~~~~~~~

ソースコード

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