結果

問題 No.1538 引きこもりさんは引き算が得意。
ユーザー yulianess27__yulianess27__
提出日時 2021-06-17 18:11:06
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 1,573 bytes
コンパイル時間 1,412 ms
コンパイル使用メモリ 18,640 KB
実行使用メモリ 175,016 KB
最終ジャッジ日時 2023-08-31 01:33:47
合計ジャッジ時間 6,784 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
23,388 KB
testcase_01 AC 16 ms
18,876 KB
testcase_02 AC 16 ms
19,008 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 15 ms
19,092 KB
testcase_09 AC 15 ms
19,008 KB
testcase_10 AC 75 ms
19,028 KB
testcase_11 AC 16 ms
19,032 KB
testcase_12 AC 17 ms
19,016 KB
testcase_13 AC 16 ms
19,120 KB
testcase_14 AC 15 ms
19,124 KB
testcase_15 WA -
testcase_16 AC 17 ms
19,056 KB
testcase_17 AC 16 ms
19,032 KB
testcase_18 AC 15 ms
19,064 KB
testcase_19 AC 16 ms
19,004 KB
testcase_20 AC 16 ms
19,008 KB
testcase_21 AC 16 ms
19,120 KB
testcase_22 AC 16 ms
19,036 KB
testcase_23 AC 16 ms
19,008 KB
testcase_24 AC 15 ms
19,008 KB
testcase_25 AC 16 ms
19,000 KB
testcase_26 AC 16 ms
19,124 KB
testcase_27 AC 16 ms
19,008 KB
testcase_28 AC 16 ms
18,856 KB
testcase_29 AC 16 ms
19,092 KB
testcase_30 AC 16 ms
18,872 KB
testcase_31 AC 16 ms
19,132 KB
testcase_32 WA -
testcase_33 AC 16 ms
19,032 KB
testcase_34 AC 16 ms
18,840 KB
testcase_35 AC 16 ms
18,908 KB
testcase_36 AC 16 ms
19,200 KB
testcase_37 TLE -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
// 黒板に N 個の整数  が書かれています.引き算が得意なゅゅちゃんは 0 以上 N-1 以下の任意の回数,以下の操作を繰り返すことができます.

// 黒板に書かれている数を 2 つ選んで消す.消した数を  として, と x-y, y-x のどちらか一方を黒板に書く.
// この操作によって,黒板に書かれている数に K が含まれている状態にすることができるか判定してください.

list($n, $k) = explode(" ", trim(fgets(STDIN)));

$list = explode(" ", trim(fgets(STDIN)));

if (in_array($k, $a)) echo 'Yes';

// 順列
function permutations(array $elements)
{
    if (count($elements) <= 1) {
        yield $elements;
    } else {
        foreach (permutations(array_slice($elements, 1)) as $permutation) {
            foreach (range(0, count($elements) - 1) as $i) {
                yield array_merge(
                    array_slice($permutation, 0, $i),
                    [$elements[0]],
                    array_slice($permutation, $i)
                );
            }
        }
    }
}

foreach (permutations($list) as $permutation) {
    $r = [];
    foreach($permutation as $v) {
        if (empty($r)) {
            $r = [$v, -$v];
        } else {
            $t = [];
            foreach($r as $rr) {
                $t[] = $rr + $v; 
                $t[] = $rr - $v;
            }
            if (in_array($k, $r)) {
                echo "Yes";
                exit;
            }
            $r = array_unique($t);
        }
    }
}
echo "No";
0