結果

問題 No.2358 xy+yz+zx=N
ユーザー 👑 kakel-sankakel-san
提出日時 2023-08-17 10:21:50
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 991 ms / 2,000 ms
コード長 975 bytes
コンパイル時間 2,286 ms
コンパイル使用メモリ 66,072 KB
実行使用メモリ 29,960 KB
最終ジャッジ日時 2023-08-17 10:22:01
合計ジャッジ時間 9,486 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
23,564 KB
testcase_01 AC 60 ms
21,644 KB
testcase_02 AC 60 ms
19,540 KB
testcase_03 AC 60 ms
23,696 KB
testcase_04 AC 85 ms
21,540 KB
testcase_05 AC 59 ms
23,608 KB
testcase_06 AC 59 ms
23,584 KB
testcase_07 AC 62 ms
21,524 KB
testcase_08 AC 991 ms
29,960 KB
testcase_09 AC 966 ms
28,228 KB
testcase_10 AC 954 ms
26,232 KB
testcase_11 AC 972 ms
24,488 KB
testcase_12 AC 766 ms
23,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var ans = new List<int[]>();
        for (var x = 0; x <= n; ++x) for (var y = 0; y <= n; ++y)
        {
            if (x == 0 && y == 0) continue;
            if (x * y > n) break;
            if ((n - x * y) % (x + y) == 0) ans.Add(new int[] { x, y, (n - x * y) / (x + y) });
        }
        WriteLine(ans.Count);
        WriteLine(string.Join("\n", ans.Select(ai => string.Join(" ", ai))));
    }
}
0