結果
| 問題 |
No.164 ちっちゃくないよ!!
|
| コンテスト | |
| ユーザー |
TLwiegehtt
|
| 提出日時 | 2015-07-12 02:54:36 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 938 bytes |
| コンパイル時間 | 174 ms |
| コンパイル使用メモリ | 21,760 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-13 14:16:29 |
| 合計ジャッジ時間 | 779 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 |
コンパイルメッセージ
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);
| ^~~~~~~~~~~~~~
ソースコード
#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;
}
TLwiegehtt