結果

問題 No.1006 Share an Integer
ユーザー lotus
提出日時 2020-03-11 13:55:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 881 bytes
コンパイル時間 4,646 ms
コンパイル使用メモリ 167,520 KB
実行使用メモリ 11,304 KB
最終ジャッジ日時 2024-11-16 00:08:57
合計ジャッジ時間 5,131 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n;
int dp[2020202];
void solve(){
	cin >> n;
	
	for(int i = 0; i < 2020202; i++) dp[i] = i;
	for(int i = 1; i < 2020202; i++){
		for(int j = i; j < 2020202; j+=i){
			dp[j]--;
		}
	}
	
	int mi = INF;
	for(int i = 1; i < n; i++){
		chmin(mi, abs(dp[i]-dp[n-i]));
	}
	for(int i = 1; i < n; i++){
		if(mi == abs(dp[i]-dp[n-i])) cout << i << " " << n-i << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}
0