結果
問題 | No.1006 Share an Integer |
ユーザー | betrue12 |
提出日時 | 2020-03-06 21:38:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 75 ms / 2,000 ms |
コード長 | 631 bytes |
コンパイル時間 | 2,356 ms |
コンパイル使用メモリ | 203,292 KB |
最終ジャッジ日時 | 2025-01-09 04:52:31 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int X; cin >> X; vector<int> num(X+1); for(int i=1; i<=X; i++) for(int j=i; j<=X; j+=i) num[j]++; int opt = 1e9; vector<pair<int, int>> ans; for(int i=1; i<=X-i; i++){ int j = X-i; int d = abs((i-num[i]) - (j-num[j])); if(opt > d){ ans.clear(); opt = d; } if(opt == d){ ans.emplace_back(i, j); if(i < j) ans.emplace_back(j, i); } } sort(ans.begin(), ans.end()); for(auto& p : ans) printf("%d %d\n", p.first, p.second); return 0; }