結果

問題 No.1006 Share an Integer
ユーザー kk
提出日時 2020-07-02 06:00:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 578 bytes
コンパイル時間 1,954 ms
コンパイル使用メモリ 199,412 KB
実行使用メモリ 10,812 KB
最終ジャッジ日時 2023-10-12 17:52:53
合計ジャッジ時間 3,746 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 38 ms
7,436 KB
testcase_12 AC 79 ms
10,208 KB
testcase_13 AC 87 ms
10,676 KB
testcase_14 AC 86 ms
10,732 KB
testcase_15 AC 68 ms
9,812 KB
testcase_16 AC 29 ms
6,476 KB
testcase_17 AC 38 ms
7,380 KB
testcase_18 AC 69 ms
9,680 KB
testcase_19 AC 62 ms
9,672 KB
testcase_20 AC 75 ms
10,080 KB
testcase_21 AC 85 ms
10,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int x;
  cin >> x;

  vector<int> divs(x + 1);
  for (int i = 1; i <= x; i++) 
    for (int j = i; j <= x; j += i)
      divs[j]++;
  
  int ret = 1e8;
  for (int a = 1; a < x; a++) {
    int b = x - a;
    ret = min(ret, abs(a - divs[a] - (b - divs[b])));
  }
  
  for (int a = 1; a < x; a++) {
    int b = x - a;
    if (abs(a - divs[a] - (b - divs[b])) == ret)
      cout << a << " " << b << endl;
  }

  return 0;
}
0