結果

問題 No.2479 Sum of Squares
ユーザー bluemeganebluemegane
提出日時 2023-09-22 22:28:12
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 684 bytes
コンパイル時間 1,571 ms
コンパイル使用メモリ 63,164 KB
実行使用メモリ 22,788 KB
最終ジャッジ日時 2023-09-22 22:28:27
合計ジャッジ時間 5,441 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
20,772 KB
testcase_01 AC 60 ms
20,724 KB
testcase_02 AC 60 ms
22,788 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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

using System.Collections.Generic;
using static System.Math;
using System;

public class Hello
{
    static void Main()
    {
        var s = long.Parse(Console.ReadLine().Trim());
        getAns(s);
    }
    static long calc (long t)
    {
        var a = (long) Sqrt(t);
        var w = (a + 1) * (a + 1);
        if (w == t) return w;
        else return a * a;
    }
    static void getAns(long s)
    {
        var ans = new List<long>();
        while (true)
        {
            var w = calc(s);
            ans.Add(w);
            s -= w;
            if (s == 0) break;
        }
        Console.WriteLine(ans.Count);
        Console.WriteLine(string.Join(" ",ans));
    }
}
0