結果
問題 |
No.1006 Share an Integer
|
ユーザー |
|
提出日時 | 2022-10-07 12:19:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 66 ms / 2,000 ms |
コード長 | 767 bytes |
コンパイル時間 | 1,970 ms |
コンパイル使用メモリ | 196,488 KB |
最終ジャッジ日時 | 2025-02-07 22:34:38 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int X; cin >> X; vector<int> div_cnt(X + 1, 2); div_cnt[1] = 1; for(int i = 2; i <= X; i++) for(int j = i * 2; j <= X; j += i) div_cnt[j]++; vector<pair<int,int>> ans; int mi = 1e9; for(int A = 1; A < X; A++) { int B = X - A; int score = abs((A - div_cnt[A]) - (B - div_cnt[B])); if(score < mi) { mi = score; ans.clear(); ans.push_back({A, B}); } else if(score == mi) { ans.push_back({A, B}); } } for(auto [A, B] : ans) cout << A << " " << B << "\n"; }