結果

問題 No.1006 Share an Integer
ユーザー cureskolcureskol
提出日時 2020-04-13 22:15:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,188 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 1,693 ms
コンパイル使用メモリ 170,512 KB
実行使用メモリ 120,156 KB
最終ジャッジ日時 2023-10-26 02:54:30
合計ジャッジ時間 13,806 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
55,968 KB
testcase_01 AC 23 ms
55,968 KB
testcase_02 AC 23 ms
55,980 KB
testcase_03 AC 22 ms
55,964 KB
testcase_04 AC 23 ms
55,988 KB
testcase_05 AC 23 ms
56,004 KB
testcase_06 AC 22 ms
56,008 KB
testcase_07 AC 22 ms
56,016 KB
testcase_08 AC 22 ms
56,000 KB
testcase_09 AC 23 ms
56,016 KB
testcase_10 AC 23 ms
56,008 KB
testcase_11 AC 631 ms
91,736 KB
testcase_12 AC 1,122 ms
116,596 KB
testcase_13 AC 1,187 ms
120,140 KB
testcase_14 AC 1,167 ms
120,156 KB
testcase_15 AC 1,015 ms
110,900 KB
testcase_16 AC 468 ms
82,900 KB
testcase_17 AC 651 ms
92,612 KB
testcase_18 AC 1,023 ms
111,324 KB
testcase_19 AC 975 ms
108,900 KB
testcase_20 AC 1,105 ms
113,000 KB
testcase_21 AC 1,188 ms
120,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

vector<int> yaku[2234567];

int f(int a){
  int cnt=1;
  for(int p:yaku[a])cnt*=p+1;
  return a-cnt;
}
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}

signed main(){
  int x;cin>>x;
  for(int i=2;i<=x;i++){
    if(yaku[i].size())continue;
    for(int j=i;j<=x;j+=i){
      int tmp=j,cnt=0;
      while(tmp%i==0){
        tmp/=i;
        cnt++;
      }
      yaku[j].push_back(cnt);
    }
  }
  int ans=1e9;
  for(int a=1;a<x;a++)chmin(ans,abs(f(a)-f(x-a)));
  for(int a=1;a<x;a++)if(abs(f(a)-f(x-a))==ans)cout<<a<<" "<<x-a<<endl;
}
0