結果
| 問題 |
No.1006 Share an Integer
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-05-04 03:32:30 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,731 bytes |
| コンパイル時間 | 2,312 ms |
| コンパイル使用メモリ | 207,876 KB |
| 実行使用メモリ | 57,800 KB |
| 最終ジャッジ日時 | 2025-05-04 03:32:40 |
| 合計ジャッジ時間 | 9,257 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)
#define all(x) begin(x), end(x)
template <typename T> bool chmin(T& x, T y) {
return x > y ? (x = y, true) : false;
}
template <typename T> bool chmax(T& x, T y) {
return x < y ? (x = y, true) : false;
}
struct IOST {
IOST() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(20);
}
} IOST;
namespace cho {
using std::vector;
vector<int> prime_table(int n) {
vector<int> p(n + 1, -1);
for (int i = 2; i * i <= n; i++) {
if (p[i] != -1) continue;
for (int j = i * i; j <= n; j += i) {
p[j] = i;
}
p[i] = i;
}
return p;
}
std::set<int> prime_set(int n) {
std::set<int> res;
auto p = prime_table(n);
for (int i = 2; i <= n; i++) {
if (p[i] == i) res.insert(i);
}
return res;
}
vector<int> prime_list(int n) {
vector<int> res;
auto p = prime_table(n);
for (int i = 2; i <= n; i++) {
if (p[i] == i) res.push_back(i);
}
return res;
}
std::map<int, int> table_factor(int n) {
const static vector<int> table = prime_table(1e7);
assert(n <= 1e7);
std::map<int, int> res;
while (n > 1) {
res[table[n]]++;
n /= table[n];
}
return res;
}
} // namespace cho
void solve() {
auto d_N = [](int n) {
if (n <= 0) return 0LL;
auto mp = cho::table_factor(n);
ll res = 1;
for (auto [x, ct] : mp) res *= (ct + 1);
return res;
};
int n;
cin >> n;
vector<ll> f(n + 1);
rep(i, 0, n + 1) f[i] = i - d_N(i);
ll mn = 1e18;
rep(i, 0, n + 1) chmin(mn, abs(f[i] - f[n - i]));
rep(i, 0, n + 1) {
if (mn == abs(f[i] - f[n - i])) cout << i << " " << n - i << "\n";
}
}
int main() {
int t = 1;
// cin >> t;
rep(i, 0, t) solve();
}