結果
問題 |
No.1006 Share an Integer
|
ユーザー |
![]() |
提出日時 | 2020-03-06 21:56:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 15 ms / 2,000 ms |
コード長 | 834 bytes |
コンパイル時間 | 723 ms |
コンパイル使用メモリ | 74,976 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-14 06:41:39 |
合計ジャッジ時間 | 1,802 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> using namespace std; using ll = long long; int main() { int x; cin >> x; auto f = [](int n) { int k = 0; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { k += 2; if (i * i == n) k--; } } return n - k; }; int d = 1 << 30; for (int a = 1; a < x; a++) { int b = x - a; if (abs(a - b) >= 600) continue; int c = abs(f(a) - f(b)); d = min(d, c); } for (int a = 1; a < x; a++) { int b = x - a; if (abs(a - b) >= 600) continue; int c = abs(f(a) - f(b)); if (c == d) cout << a << ' ' << b << '\n'; } return 0; }