結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 35 ms
7,552 KB
testcase_12 AC 75 ms
10,592 KB
testcase_13 AC 83 ms
11,008 KB
testcase_14 AC 80 ms
11,032 KB
testcase_15 AC 67 ms
9,980 KB
testcase_16 AC 25 ms
6,400 KB
testcase_17 AC 36 ms
7,552 KB
testcase_18 AC 68 ms
9,984 KB
testcase_19 AC 60 ms
9,728 KB
testcase_20 AC 67 ms
10,112 KB
testcase_21 AC 79 ms
10,880 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