結果

問題 No.193 筒の数式
ユーザー masachacomasachaco
提出日時 2015-04-27 04:20:19
言語 PHP
(8.3.4)
結果
AC  
実行時間 15 ms / 1,000 ms
コード長 751 bytes
コンパイル時間 64 ms
コンパイル使用メモリ 18,744 KB
実行使用メモリ 19,132 KB
最終ジャッジ日時 2023-09-18 12:43:21
合計ジャッジ時間 1,193 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
19,036 KB
testcase_01 AC 14 ms
18,772 KB
testcase_02 AC 15 ms
18,944 KB
testcase_03 AC 14 ms
19,132 KB
testcase_04 AC 14 ms
18,916 KB
testcase_05 AC 14 ms
19,004 KB
testcase_06 AC 14 ms
18,896 KB
testcase_07 AC 15 ms
18,772 KB
testcase_08 AC 14 ms
19,076 KB
testcase_09 AC 15 ms
18,932 KB
testcase_10 AC 14 ms
18,912 KB
testcase_11 AC 15 ms
19,040 KB
testcase_12 AC 15 ms
18,956 KB
testcase_13 AC 15 ms
18,996 KB
testcase_14 AC 15 ms
18,984 KB
testcase_15 AC 15 ms
18,896 KB
testcase_16 AC 15 ms
18,972 KB
testcase_17 AC 15 ms
19,016 KB
testcase_18 AC 15 ms
18,868 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$stdin = trim(fgets(STDIN)); 

$n = strlen($stdin);
$ans = null;
for ($i = 0; $i < $n ;$i++){
$func = $stdin;
if($i!=0){
$func1 = substr($stdin ,0,$i);
$func2 = substr($stdin ,$i,$n-$i);
$func = $func2.$func1;
}
$s=$func[0];
$e = $func[$n-1];
if($s==='+'||$s==='-'||$e==='+'||$e==='-'){
continue;
}

$result = "";

$func = preg_replace('(^0+)','',$func);
$func = preg_replace('(^\+)','0+',$func);
$func = preg_replace('(^\-)','0-',$func);
$func = preg_replace('(\+0+$)','+a',$func);
$func = preg_replace('(\-0+$)','-a',$func);
$func = preg_replace('(\+0+)','+',$func);
$func = preg_replace('(\-0+)','-',$func);
$func = preg_replace('(a)','0',$func);
eval('$result = '.$func.';');
if ($ans==null || $ans < $result){
$ans = $result;
}
}
echo $ans;
0