結果
問題 | No.164 ちっちゃくないよ!! |
ユーザー |
|
提出日時 | 2015-05-16 19:55:38 |
言語 | PHP (843.2) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 1,025 bytes |
コンパイル時間 | 3,159 ms |
コンパイル使用メモリ | 32,144 KB |
実行使用メモリ | 31,596 KB |
最終ジャッジ日時 | 2024-10-13 14:15:45 |
合計ジャッジ時間 | 4,365 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php $nums = trim(fgets(STDIN)); $min_value = 0; $min_text = ""; $min_base = 0; for ( $i=0; $i<$nums; $i++ ) { $input = trim(fgets(STDIN)); $base = get_base($input); $value = base_convert($input, $base, 10); if ( ($i == 0) || ($min_value > $value) ) { $min_value = $value; $min_text = $input; $min_base = $base; } } $min_text_len = strlen($min_text); $gmp_num = gmp_init(0); for ( $i=0; $i<$min_text_len; $i++ ) { $text = substr($min_text, 0, 1); $min_text = substr($min_text, 1); $gmp_num = gmp_mul($gmp_num, gmp_init($min_base)); $gmp_num = gmp_add($gmp_num, gmp_init(base_convert($text, $min_base, 10))); } echo gmp_strval($gmp_num).PHP_EOL; function get_base ( $string ) { $count = count_chars($string,1); $key = ord('Z'); while ( array_key_exists($key,$count) !== TRUE ) { if ( $key == ord('A') ) { $key = ord('9'); } else { $key--; } } if ( $key >= ord('A') ) { $base = $key - 54; } else if ( $key >= ord('1') ) { $base = $key - 47; } else { $base = 2; } return $base; }