結果

問題 No.164 ちっちゃくないよ!!
コンテスト
ユーザー nablaenergy_21
提出日時 2015-05-25 13:35:22
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 737 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 192 ms
コンパイル使用メモリ 40,832 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-01 00:53:54
合計ジャッジ時間 966 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:44:15: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   44 |         printf("%lld\n",ans);
      |         ~~~~~~^~~~~~~~~~~~~~
main.cpp:16:21: note: 'ans' was declared here
   16 |         long long m,ans;
      |                     ^~~

ソースコード

diff #
raw source code

#include<stdio.h>
#include<string.h>

int max(int a,int b){
	if(a>b){return a;}else{return b;}
}

long long min(long long a,long long b){
	if(a<b){return a;}else{return b;}
}

int main(void){
	int N;
	char V[1000][13];
	int i,j,c;
	long long m,ans;

	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%s",&V[i]);
	}

	for(i=0;i<N;i++){
		c=0;
		for(j=0;j<strlen(V[i]);j++){
			if('0' <= V[i][j] && V[i][j] <= '9'){
				c = max(c,V[i][j] - '0');
			}else{
				c = max(c,V[i][j]  - 'A' + 10);
			}
		}
		c++;

		m = 0;
		for(j=0;j<strlen(V[i]);j++){
			if('0' <= V[i][j] && V[i][j] <= '9'){
				m = m*c + V[i][j] - '0';
			}else{
				m = m*c + V[i][j] - 'A' + 10;
			}
		}
		if(i==0){ans = m;}else{ans = min(ans,m);}
	}
	printf("%lld\n",ans);

}
0