結果

問題 No.550 夏休みの思い出(1)
ユーザー takeya_okino
提出日時 2017-07-30 11:52:37
言語 PHP
(843.2)
結果
AC  
実行時間 513 ms / 2,000 ms
コード長 649 bytes
コンパイル時間 935 ms
コンパイル使用メモリ 32,020 KB
実行使用メモリ 32,660 KB
最終ジャッジ日時 2024-10-11 05:42:25
合計ジャッジ時間 10,369 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 55
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$array = explode(" ", trim(fgets(STDIN)));
$A = $array[0];
$B = $array[1];
$C = $array[2];
$x1 = 0;
for($i = 0; $i < pow(10, 6); $i++) {
  $x = $i;
  $y = pow($x, 3) + $A * pow($x, 2) + $B * $x + $C;
  if($y == 0) {
    $x1 = $x;
    break;
  }
  $x = (-1) * $i;
  $y = pow($x, 3) + $A * pow($x, 2) + $B * $x + $C;
  if($y == 0) {
    $x1 = $x;
    break;
  }
}
$b = $A + $x1;
$c = $x1 * $A + pow($x1, 2) + $B;
$x2 = ((-1) * $b - sqrt(pow($b, 2) - 4 * $c)) / 2;
$x3 = ((-1) * $b + sqrt(pow($b, 2) - 4 * $c)) / 2;
$ans = array($x1, $x2, $x3);
sort($ans);
for($i = 0; $i < 3; $i++) {
  print($ans[$i]);
  if($i < 2) print(" ");
}
print("\n");
?>
0