結果
問題 | No.2358 xy+yz+zx=N |
ユーザー |
![]() |
提出日時 | 2023-06-24 22:52:48 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 79 ms / 2,000 ms |
コード長 | 2,310 bytes |
コンパイル時間 | 921 ms |
コンパイル使用メモリ | 105,600 KB |
実行使用メモリ | 23,808 KB |
最終ジャッジ日時 | 2024-07-02 01:50:25 |
合計ジャッジ時間 | 2,819 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Text;using System.Collections.Generic;using System;public class P{public int x { get; set; }public int y { get; set; }public int z { get; set; }}public class Hello{static void Main(){var n = int.Parse(Console.ReadLine().Trim());getAns(n);}static void print(List<P> ps){var c = 0;var sb = new StringBuilder();foreach (var x in ps){if (x.x == x.y && x.y == x.z){c++;sb.Append(string.Format("{0} {1} {2}\n", x.x, x.y, x.z));}else if (x.x == x.y){c += 3;sb.Append(string.Format("{0} {1} {2}\n", x.x, x.y, x.z));sb.Append(string.Format("{0} {1} {2}\n", x.x, x.z, x.y));sb.Append(string.Format("{0} {1} {2}\n", x.z, x.x, x.y));}else if (x.y == x.z){c += 3;sb.Append(string.Format("{0} {1} {2}\n", x.x, x.y, x.z));sb.Append(string.Format("{0} {1} {2}\n", x.y, x.x, x.z));sb.Append(string.Format("{0} {1} {2}\n", x.y, x.z, x.x));}else{c += 6;sb.Append(string.Format("{0} {1} {2}\n", x.x, x.y, x.z));sb.Append(string.Format("{0} {1} {2}\n", x.x, x.z, x.y));sb.Append(string.Format("{0} {1} {2}\n", x.y, x.x, x.z));sb.Append(string.Format("{0} {1} {2}\n", x.y, x.z, x.x));sb.Append(string.Format("{0} {1} {2}\n", x.z, x.x, x.y));sb.Append(string.Format("{0} {1} {2}\n", x.z, x.y, x.x));}}Console.WriteLine(c);Console.Write(sb);}static void getAns(int n){var ps = new List<P>();for (int i = 0; i * i <= n; i++){for (int j = i; j * j <= n; j++){if (i == 0 && j == 0) continue;var w = n - i * j;if (w % (i + j) == 0){var z = w / (i + j);if (z >= j) ps.Add(new P { x = i, y = j, z = z });}}}print(ps);}}