結果
| 問題 |
No.164 ちっちゃくないよ!!
|
| コンテスト | |
| ユーザー |
meshedgear
|
| 提出日時 | 2015-03-15 11:16:53 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 749 bytes |
| コンパイル時間 | 212 ms |
| コンパイル使用メモリ | 21,888 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-13 14:12:35 |
| 合計ジャッジ時間 | 588 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 |
コンパイルメッセージ
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);
| ^~~~~~~~~~~~~~~~
ソースコード
#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;
}
meshedgear