結果

問題 No.1006 Share an Integer
ユーザー MayimgMayimg
提出日時 2020-03-07 05:59:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 2,545 ms
コンパイル使用メモリ 199,216 KB
実行使用メモリ 11,076 KB
最終ジャッジ日時 2024-04-22 11:52:58
合計ジャッジ時間 3,309 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 34 ms
7,600 KB
testcase_12 AC 77 ms
10,556 KB
testcase_13 AC 81 ms
11,076 KB
testcase_14 AC 80 ms
10,984 KB
testcase_15 AC 67 ms
9,828 KB
testcase_16 AC 26 ms
6,940 KB
testcase_17 AC 37 ms
7,688 KB
testcase_18 AC 66 ms
9,948 KB
testcase_19 AC 60 ms
9,672 KB
testcase_20 AC 69 ms
10,116 KB
testcase_21 AC 80 ms
10,968 KB
権限があれば一括ダウンロードができます

ソースコード

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