q1.php
<?php
// {{{ get input module
// debug input file name
define('DEBUG_FILENAME', 'input.txt');
/* first module start (setup $input) */
if(file_exists(DEBUG_FILENAME))
{
$inputs = explode("\n---\n", file_get_contents(DEBUG_FILENAME));
define('DEBUG', TRUE);
} else
{
$inputs = array(file_get_contents('php://stdin'));
define('DEBUG', FALSE);
}
foreach ($inputs as $i => $input) {
if (DEBUG) {
echo "\n----- {$i} -----\n";
$time_start = microtime(true);
}
solve($input);
if (DEBUG) {
$time_end = microtime(true);
$time = $time_end - $time_start;
echo sprintf("\n[%.5fms]", $time * 1000);
}
}
// }}} -end
function solve($input) {
list($a, $b) = explode("\n", trim($input));
echo $a * $b . PHP_EOL;
}
solve関数の中に実行コードを書く
$inputが入力値テキスト
input.txtにテストケースを"---"区切りで入力しておく
input.txt
10
4
---
200
3
---
3
20
上記コードでの実行結果
----- 0 -----
40
[0.01884ms]
----- 1 -----
600
[0.00381ms]
----- 2 -----
60
[0.00310ms]
AtCoder,AOJ では確認済みだが phpコードはそのまま提出して問題ない