結果

問題 No.1006 Share an Integer
ユーザー Mayimg
提出日時 2020-03-07 05:58:11
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 615 bytes
コンパイル時間 2,332 ms
コンパイル使用メモリ 196,972 KB
最終ジャッジ日時 2025-01-09 05:42:21
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int x;
  cin >> x;
  vector<int> scores(x + 1);
  iota(scores.begin(), scores.end(), 0);
  for (int i = 1; i <= x; i++) for (int j = i; j <= x; j += i) --scores[j];
  int mi = 1 << 30;
  for (int i = 1; i <= x; i++) mi = min(mi, abs(scores[i] - scores[x - i]));
  vector<pair<int, int>> ans;
  for (int i = 1; i <= x; i++) if (abs(scores[i] - scores[x - i]) == mi) ans.emplace_back(i, x - i);
  for (auto& p : ans) {
    cout << p.first << " " << p.second << '\n';
  }
  return 0;
}
0