結果
| 問題 |
No.2358 xy+yz+zx=N
|
| コンテスト | |
| ユーザー |
jabee
|
| 提出日時 | 2023-06-23 22:22:17 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 814 ms / 2,000 ms |
| コード長 | 2,637 bytes |
| コンパイル時間 | 5,842 ms |
| コンパイル使用メモリ | 180,096 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-01 17:36:13 |
| 合計ジャッジ時間 | 10,524 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <atcoder/all>
#include <atcoder/dsu>
#include <atcoder/segtree>
#include <atcoder/lazysegtree>
#include <atcoder/modint>
#include <atcoder/scc>
#include <chrono>
#include <random>
#include <cassert>
#ifndef templete
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;
using namespace atcoder;
//using atmint = modint998244353;
using atmint = modint;
using Graph = vector<vector<int>>;
using P = pair<long long,long long>;
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
#endif // templete
//---------------------------------------------------------------------------------------------------
void _main() {
ll n;
cin >> n;
vector<vector<ll>>ans;
for(ll x = 1; x <= n; x++){
ll maxy = n / x;
for(ll y = 1; y <= maxy; y++){
ll r = n - x * y;
ll l = x + y;
ll z = r / l;
if(z == 0)continue;
if(r % l != 0)continue;
ans.push_back({x,y,z});
// if(r % l == 0)ans.emplace_back(x,y,z);
//if(r % l == 0)ans.push_back({x,y,z});
}
}
for(ll y = 1; y <= n; y++){
if(n % y == 0){
/*
ans.emplace_back(0,y,n/y);
ans.emplace_back(n/y,0,y);
ans.emplace_back(y,n/y,0);
*/
ans.push_back({0,y,n/y});
ans.push_back({n/y,0,y});
ans.push_back({y,n/y,0});
}
}
/*
for(ll z = 1; z <= n; z++){
if(n % z == 0)ans.emplace_back(n/z,0,z);
}
for(ll x = 1; x <= n; x++){
if(n % x == 0)ans.emplace_back(x,n/x,0);
}
*/
cout << ans.size() << endl;
rep(i,0,ans.size()){
cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << "\n";
/*
ll x;
ll y;
ll z;
tie(x,y,z) = ans[i];
cout << x << " " << y << " " << z << "\n";
*/
}
}
jabee