結果
| 問題 |
No.1006 Share an Integer
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-24 16:30:54 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,610 bytes |
| コンパイル時間 | 2,066 ms |
| コンパイル使用メモリ | 176,000 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-31 15:11:47 |
| 合計ジャッジ時間 | 2,549 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
int d(int i){
int cnt = 1;
int p = i;
for(int j=2; j*j<=i;j++){
if(p%j == 0){
int q = 0;
while(p%j == 0){
q ++;
p /= j;
}
cnt *= q + 1;
}
}
if(p > 1) cnt *= 2;
return cnt;
}
int main() {
//clock_t start = clock();
int x;
cin >> x;
int m = INF;
int a = x/2;
vector<pair<int,int>> ans;
rep(i,min(300,x/2)){
int f = abs(a-d(a) - (x-a - d(x-a)));
if(f < m){
if(a == x-a){
ans = {pp(a,x-a)};
m = f;
}
else{
ans = {pp(a,x-a),pp(x-a,a)};
m = f;
}
}
else if(f == m){
ans.push_back(pp(a,x-a));
ans.push_back(pp(x-a,a));
}
-- a;
}
sort(ans.begin(),ans.end());
for(auto a:ans) cout << a.first << " " << a.second << endl;
//clock_t end = clock();
//printf("%.7f",(double)(end - start)/CLOCKS_PER_SEC);
return 0;
}