結果

問題 No.1006 Share an Integer
ユーザー batsumarubatsumaru
提出日時 2020-03-06 22:29:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 871 bytes
コンパイル時間 1,507 ms
コンパイル使用メモリ 164,384 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2024-04-22 08:54:31
合計ジャッジ時間 5,432 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 3 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 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int x;
  cin >> x;
  vector<int> d(x,0);
  FOR(i,1,x){
    for(int j=1; j*j <=i; j++){
      if(i%j!=0){
        continue;
      }
      if(j*j==i){
        d[i]++;
        break;
      }
      d[i] += 2;
    }
  }
  vector<int> score(x+1);
  int mini = 1e9;
  FOR(i,1,x){
    score[i] = abs(i-d[i]-(x-i-d[x-i]));
    mini = min(mini,score[i]);
  }
  FOR(i,1,x){
    if(score[i] == mini){
      printf("%lld %lld\n", i, x-i);
    }
  }
}
0