結果

問題 No.1006 Share an Integer
ユーザー eQeeQe
提出日時 2020-03-07 13:07:10
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,166 bytes
コンパイル時間 1,634 ms
コンパイル使用メモリ 171,928 KB
実行使用メモリ 347,372 KB
最終ジャッジ日時 2024-04-22 12:52:40
合計ジャッジ時間 6,460 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
105,152 KB
testcase_01 AC 71 ms
98,108 KB
testcase_02 AC 70 ms
98,216 KB
testcase_03 AC 70 ms
98,000 KB
testcase_04 AC 74 ms
98,124 KB
testcase_05 AC 71 ms
98,220 KB
testcase_06 AC 70 ms
98,440 KB
testcase_07 AC 71 ms
98,280 KB
testcase_08 AC 72 ms
98,308 KB
testcase_09 AC 72 ms
98,492 KB
testcase_10 AC 72 ms
98,416 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[MAX*10*2];
void factrization(ll n) {
  ll id=n;
  for(ll i=2; i*i<=n; i++) {
    while(n%i==0) {
      prime[id][i]++;
      n/=i;
    }
  }
  
  if(n>1) prime[id][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=1; i<X; i++) {
    ll A=i;
    ll B=X-i;
    
    ll da=1;
    for(auto it=prime[A].begin(); it!=prime[A].end(); it++) {
      da*=it->second+1;
    }
    
    ll db=1;
    for(auto it=prime[B].begin(); it!=prime[B].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