結果

問題 No.193 筒の数式
ユーザー masachaco
提出日時 2015-04-27 04:20:19
言語 PHP
(843.2)
結果
AC  
実行時間 46 ms / 1,000 ms
コード長 751 bytes
コンパイル時間 70 ms
コンパイル使用メモリ 32,016 KB
実行使用メモリ 31,260 KB
最終ジャッジ日時 2024-07-05 03:30:48
合計ジャッジ時間 1,634 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
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