結果

問題 No.1006 Share an Integer
ユーザー iqueue02iqueue02
提出日時 2020-07-29 15:07:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 675 bytes
コンパイル時間 3,039 ms
コンパイル使用メモリ 200,172 KB
実行使用メモリ 11,016 KB
最終ジャッジ日時 2023-09-11 07:16:21
合計ジャッジ時間 4,705 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 38 ms
7,420 KB
testcase_12 AC 80 ms
10,416 KB
testcase_13 AC 88 ms
10,736 KB
testcase_14 AC 87 ms
10,656 KB
testcase_15 AC 67 ms
9,864 KB
testcase_16 AC 27 ms
6,496 KB
testcase_17 AC 37 ms
7,452 KB
testcase_18 AC 72 ms
9,716 KB
testcase_19 AC 63 ms
9,620 KB
testcase_20 AC 73 ms
10,104 KB
testcase_21 AC 86 ms
11,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;
int main() {
  int x;
  cin >> x;
  vector<int> d(x + 1, 0);
  for (int i = 1; i <= x; i++) {
    for (int j = i; j <= x; j += i) d[j]++;
  }
  
  int res = INF;

  for ( int i = 1; i < x; i++) {
    int j = x - i;
    int fa = i - d[i], fb = j - d[j];
    res = min(res, abs(fa - fb));
  }

  for ( int i = 1; i < x; i++) {
    int j = x - i;
    int fa = i - d[i], fb = j - d[j];
    if (abs(fa - fb) == res) cout << i << " " << j << endl;
  }
  return 0;
} 
0