結果

問題 No.1006 Share an Integer
ユーザー eQeeQe
提出日時 2020-03-07 13:57:34
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,232 bytes
コンパイル時間 1,784 ms
コンパイル使用メモリ 173,112 KB
実行使用メモリ 16,032 KB
最終ジャッジ日時 2024-04-22 13:04:29
合計ジャッジ時間 8,174 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


map<ll, ll> prime;
void factrization(ll n) {
  for(ll i=2; i*i<=n; i++) {
    while(n%i==0) {
      prime[i]++;
      n/=i;
    }
  }
  
  if(n>1) prime[n]++;
}



int main(void) {
  ll X;
  cin >> X;
  ll i;
  
  for(i=1; i<X; i++) factrization(i);
  
  vector<pair<ll, P>> v;
  for(i=-3*sqrt(X); i<3*sqrt(X); i++) {
    ll A=X/2-i;
    ll B=(X+1)/2+i;
    
    prime.clear();
    factrization(A);
    ll da=1;
    for(auto it=prime.begin(); it!=prime.end(); it++) {
      da*=it->second+1;
    }
    
    prime.clear();
    factrization(B);
    ll db=1;
    for(auto it=prime.begin(); it!=prime.end(); it++) {
      db*=it->second+1;
    }
    
    ll fa=A-da;
    ll fb=B-db;
    
    
    v.push_back({abs(fa-fb), {A, B}});
  }
  sort(v.begin(), v.end());
  
  ll t=v[0].first;
  for(i=0; i<v.size(); i++) {
    if(v[i].first!=t) break;
    pt(v[i].second.first<<" "<<v[i].second.second);
  }
  
  
}



0