結果

問題 No.1006 Share an Integer
ユーザー mgingin142857mgingin142857
提出日時 2020-03-06 22:01:06
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 953 bytes
コンパイル時間 1,818 ms
コンパイル使用メモリ 164,764 KB
実行使用メモリ 19,176 KB
最終ジャッジ日時 2024-04-22 07:42:26
合計ジャッジ時間 4,653 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
18,944 KB
testcase_01 AC 96 ms
19,072 KB
testcase_02 AC 94 ms
19,072 KB
testcase_03 AC 88 ms
18,944 KB
testcase_04 AC 104 ms
19,124 KB
testcase_05 AC 100 ms
19,048 KB
testcase_06 AC 94 ms
18,872 KB
testcase_07 AC 107 ms
19,072 KB
testcase_08 AC 103 ms
18,944 KB
testcase_09 AC 91 ms
18,880 KB
testcase_10 AC 91 ms
18,944 KB
testcase_11 AC 114 ms
19,072 KB
testcase_12 AC 93 ms
18,944 KB
testcase_13 AC 96 ms
19,044 KB
testcase_14 AC 99 ms
18,944 KB
testcase_15 AC 109 ms
18,944 KB
testcase_16 AC 92 ms
19,072 KB
testcase_17 AC 95 ms
19,072 KB
testcase_18 AC 98 ms
19,176 KB
testcase_19 AC 92 ms
19,072 KB
testcase_20 AC 97 ms
18,944 KB
testcase_21 AC 102 ms
19,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}

int main(){
  int i,j;
  int n;
  cin>>n;
  VI v(2010101,1);
  for(i=2;i<2010101;i++){
    for(j=1;i*j<2010101;j++){
      v[i*j]++;
    }
  }
  int ans=inf;
  for(i=1;i<n;i++){
    int l=n-i;
    int x=i-v[i];
    int y=l-v[l];
    ans=min(ans,abs(x-y));
  }
  for(i=1;i<n;i++){
    int l=n-i;
    int x=i-v[i];
    int y=l-v[l];
    if(abs(x-y)==ans){
      cout<<i<<" "<<l<<endl;
    }
  }

}
0