結果
問題 | No.1006 Share an Integer |
ユーザー | kyort0n |
提出日時 | 2020-03-06 21:42:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 86 ms / 2,000 ms |
コード長 | 995 bytes |
コンパイル時間 | 1,635 ms |
コンパイル使用メモリ | 170,616 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-10-14 04:53:48 |
合計ジャッジ時間 | 4,132 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; template<class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } const long double EPS = 1e-10; const long long INF = 1e18; const long double PI = acos(-1.0L); //const ll mod = 1000000007; int d[2001000]; int main() { for(int i = 1; i <= 2e6; i++) { for(int j = i; j <= 2e6; j += i) { d[j]++; } } int X; cin >> X; vector<int> A; int val = 1e9; for(int i = 1; i < X; i++) { int now = abs(i - d[i] - (X - i) + d[X-i]); if(chmin(val, now)) { A.clear(); } if(val == now) A.push_back(i); } for(auto tmp : A) { cout << tmp << " " << X - tmp << endl; } return 0; }