結果
問題 | No.2358 xy+yz+zx=N |
ユーザー | InTheBloom |
提出日時 | 2023-07-10 18:08:08 |
言語 | D (dmd 2.106.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,063 bytes |
コンパイル時間 | 2,404 ms |
コンパイル使用メモリ | 174,068 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-12 23:43:39 |
合計ジャッジ時間 | 4,407 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,812 KB |
testcase_02 | AC | 1 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 1 ms
6,940 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
ソースコード
import std; void main () { long N = readln.chomp.to!long; solve(N); } struct trio { int X; int Y; int Z; } void solve (long N) { trio[] ans; // assume x <= y <= z foreach (x; 0..int.max) { if (N < x*x) { break; } foreach (y; x..int.max) { if (x == 0 && y == 0) { continue; } if (N < y*y) { break; } // z = (N-xy) / (x+y) if ((N-x*y) % (x+y) == 0) { if (y <= (N-x*y)/(x+y)) { ans ~= trio(x, y, cast(int) N/(x+y)); } } } } // counting length int len = 0; foreach (ref x; ans) { if (x.X != x.Y && x.X != x.Z && x.Y != x.Z) { len += 6; } else if (x.X == x.Y && x.X != x.Z) { len += 3; } else if (x.X != x.Y && x.Y == x.Z) { len += 3; } else if (x.X == x.Y && x.X == x.Z) { len += 1; } else { assert(0, "you can't reach this statement."); } } // output writeln(len); foreach (ref x; ans) { if (x.X != x.Y && x.X != x.Z && x.Y != x.Z) { writeln(x.X, " ", x.Y, " ", x.Z); writeln(x.X, " ", x.Z, " ", x.Y); writeln(x.Y, " ", x.X, " ", x.Z); writeln(x.Y, " ", x.Z, " ", x.X); writeln(x.Z, " ", x.X, " ", x.Y); writeln(x.Z, " ", x.Y, " ", x.X); } else if (x.X == x.Y && x.X != x.Z) { writeln(x.X, " ", x.Y, " ", x.Z); writeln(x.X, " ", x.Z, " ", x.Y); writeln(x.Z, " ", x.X, " ", x.Y); } else if (x.X != x.Y && x.Y == x.Z) { writeln(x.X, " ", x.Y, " ", x.Z); writeln(x.Y, " ", x.X, " ", x.Z); writeln(x.Y, " ", x.Z, " ", x.X); } else if (x.X == x.Y && x.X == x.Z) { writeln(x.X, " ", x.Y, " ", x.Z); } else { assert(0, "you can't reach this statement."); } } }