Initial commit
This commit is contained in:
53
2022/republic/d0/problem06/maxim_solution.cpp
Normal file
53
2022/republic/d0/problem06/maxim_solution.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
typedef long long ll;
|
||||
#define f first
|
||||
#define s second
|
||||
#define pb push_back
|
||||
#define mp make_pair
|
||||
#define pi pair<ll, ll>
|
||||
#define sz(x) (int)((x).size())
|
||||
#define all(a) (a).begin(), (a).end()
|
||||
|
||||
const ll mod = 1e9+7;
|
||||
ll n, k, m, mi, ma;
|
||||
|
||||
void solve(){
|
||||
cin >> n;
|
||||
|
||||
map<ll, ll> q;
|
||||
vector<pi> ans;
|
||||
for(int i = 1; i*i < n; i++) q[i*i] = i;
|
||||
for(int i = 1; i*i < n - i*i; i++){
|
||||
if(q[n - i*i] == 0) continue;
|
||||
ll j = q[n - i*i];
|
||||
ll b = j*j - i*i;
|
||||
ll a = 2*i*j;
|
||||
if(a > b) swap(a, b);
|
||||
if(a < 0) continue;
|
||||
if(__gcd(a, b) != 1 || __gcd(b, n) != 1) continue;
|
||||
ans.pb({a, b});
|
||||
}
|
||||
sort(all(ans));
|
||||
for(int i = 0; i<ans.size(); i++) cout << ans[i].f << " " << ans[i].s << " " << n << "\n";
|
||||
if(ans.size() == 0){
|
||||
cout << "NOPE\n";
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
//init();
|
||||
|
||||
int t=1;
|
||||
// cin >> t;
|
||||
while(t--) solve();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user