結果

問題 No.2479 Sum of Squares
ユーザー k kk k
提出日時 2023-11-25 01:09:57
言語 PHP
(8.3.4)
結果
TLE  
実行時間 -
コード長 514 bytes
コンパイル時間 1,606 ms
コンパイル使用メモリ 32,540 KB
実行使用メモリ 39,088 KB
最終ジャッジ日時 2023-11-25 01:10:07
合計ジャッジ時間 6,029 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
32,540 KB
testcase_01 AC 44 ms
32,540 KB
testcase_02 AC 46 ms
32,540 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$input = trim(fgets(STDIN));
$heihou = [];

for($i=$input; $i>0; $i--) {
    if (($i*$i) < $input) {
        $heihou[] = $i*$i;
    }
}

// 一番大きい数から挿れていき最後の一番小さい1で調整する
$c = $input;
$res = [];
foreach($heihou as $v) {
    if ($c - $v >= 0) {
        $c    -= $v;
        $res[] = $v;
    }
    if ($c == 0) {
        break;
    }
}

if ($c>0) {
    for ($i=$c; $i>0; $i--) {
        $res[] = 1;
    } 
}


echo count($res)."\n";
echo implode(" ", $res);
?>
0