結果
問題 |
No.1006 Share an Integer
|
ユーザー |
![]() |
提出日時 | 2020-03-06 22:15:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,217 bytes |
コンパイル時間 | 1,785 ms |
コンパイル使用メモリ | 175,532 KB |
実行使用メモリ | 13,636 KB |
最終ジャッジ日時 | 2024-10-14 07:35:26 |
合計ジャッジ時間 | 5,435 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 WA * 4 TLE * 1 -- * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair<int,int> P; constexpr int INF = 1e9; vector<long long> divisor(long long n){ vector<long long> res; for(long long i = 1; i*i <= n; i++){ if(n%i==0){ res.push_back(i); if(n/i != i)res.push_back(n/i); } } return res; } int main(){ int x; cin >> x; set<P> st; int mi = INF; for (int a = 1; a + a <= x; a++) { int b = x - a; auto d1 = divisor(a); auto d2 = divisor(b); int f1 = a - d1.size(), f2 = b - d2.size(); int v = abs(f1 - f2); if (v < mi) mi = v; } vector<P> res1, res2; for (int a = 1; a + a <= x; a++) { int b = x - a; auto d1 = divisor(a); auto d2 = divisor(b); int f1 = a - d1.size(), f2 = b - d2.size(); int v = abs(f1 - f2); if (v == mi) { res1.emplace_back(make_pair(a, b)); res2.emplace_back(make_pair(b, a)); } } reverse(res2.begin(), res2.end()); for (auto e : res1) { printf("%d %d\n", e.first, e.second); } for (auto e : res2) { printf("%d %d\n", e.first, e.second); } return 0; }