結果

問題 No.1006 Share an Integer
ユーザー chocono2230chocono2230
提出日時 2020-03-06 22:07:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,002 bytes
コンパイル時間 2,026 ms
コンパイル使用メモリ 166,560 KB
実行使用メモリ 14,016 KB
最終ジャッジ日時 2024-04-22 07:55:23
合計ジャッジ時間 5,613 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int fanc(int x){
	int ans = 0;
	if(x == 1){
		return 1;
	}
	for(int i = 1; i * i <= x; i++){
		if(i*i == x) ans++;
		else if(x % i == 0)ans += 2;
	}
	//cerr << x << " " << ans <<endl;
	return ans;
}

int main(){
	int x, mn = 1001001;
	cin >> x;
	vector<pair<int, int>> vp(x-1);
	rep2(i, 1, x){
		int j = x - i;
		int di = fanc(i), dj = fanc(j);
		int temp = fabs((i - di) - (j - dj));
		mn = min(mn, temp);
		vp.at(i-1) = make_pair(i, temp);
	}
	//cerr << "mn:" << mn << endl;
	for(auto p : vp){
		if(p.second == mn){
			cout << p.first << " " << x - p.first << endl;
		}
	}
	return 0;
}
0