結果
| 問題 |
No.2358 xy+yz+zx=N
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2023-06-25 01:14:35 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 92 ms / 2,000 ms |
| コード長 | 1,511 bytes |
| コンパイル時間 | 4,253 ms |
| コンパイル使用メモリ | 146,716 KB |
| 実行使用メモリ | 7,328 KB |
| 最終ジャッジ日時 | 2024-07-02 03:38:39 |
| 合計ジャッジ時間 | 5,886 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>
using namespace std;
typedef long long ll;
string to_s(int x, int y, int z) {
return to_string(x) + " " + to_string(y) + " " + to_string(z);
}
int main() {
int N;
cin >> N;
vector<string> ans;
map<int, map<int, bool>> checked;
int x = 0;
while (x * x <= N) {
int y = x;
while (y * y <= N) {
if (x + y != 0) {
if ((N - x * y) % (x + y) == 0) {
int z = (N - x * y) / (x + y);
if (not checked[x][y]) {
checked[x][y] = true;
ans.push_back(to_s(x, y, z));
}
if (not checked[x][z]) {
checked[x][z] = true;
ans.push_back(to_s(x, z, y));
}
if (not checked[y][x]) {
checked[y][x] = true;
ans.push_back(to_s(y, x, z));
}
if (not checked[y][z]) {
checked[y][z] = true;
ans.push_back(to_s(y, z, x));
}
if (not checked[z][x]) {
checked[z][x] = true;
ans.push_back(to_s(z, x, y));
}
if (not checked[z][y]) {
checked[z][y] = true;
ans.push_back(to_s(z, y, x));
}
}
}
++y;
}
++x;
}
cout << ans.size() << endl;
for (string s : ans) {
cout << s << endl;
}
return 0;
}
siman