結果

問題 No.2479 Sum of Squares
ユーザー bluemegane
提出日時 2023-09-22 22:28:12
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 684 bytes
コンパイル時間 951 ms
コンパイル使用メモリ 104,448 KB
実行使用メモリ 413,056 KB
最終ジャッジ日時 2024-07-08 13:12:53
合計ジャッジ時間 4,997 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other TLE * 1 -- * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

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