結果

問題 No.722 100×100=1000
ユーザー kerotang
提出日時 2019-06-03 12:55:55
言語 PHP
(843.2)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 1,391 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 31,888 KB
実行使用メモリ 31,464 KB
最終ジャッジ日時 2024-12-29 19:45:44
合計ジャッジ時間 2,622 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    /**
     * @return mixed
     */
    public function next() {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    /**
     * @return bool
     */
    public function hasNext() {
        return $this->pointer < $this->count;
    }

    /**
     * @return int
     */
    public function nextInt() {
        return (int)$this->next();
    }

    /**
     * @return float
     */
    public function nextDouble() {
        return (double)$this->next();
    }
}

function dentaku($A, $B)
{
    $result = $A * $B;
    if ($result < -99999999 || 99999999 < $result) {
        $result = 'E';
    }
    
    return $result;
}

// 初期化
$sc = new Scanner();
$yukiList = [];
for ($i = 1; $i <= 9; $i++) {
    for ($n = 2; $n < 15; $n++) {
        $yukiList[] = $i * pow(10, $n);
        $yukiList[] = -$i * pow(10, $n);
    }
}

$A = $sc->nextInt();
$B = $sc->nextInt();
if (in_array($A, $yukiList) && in_array($B, $yukiList)) {
    $result = ($A * $B) / 10;
} else {
    $result = dentaku($A, $B);
}


echo $result . "\n";
0