結果

問題 No.1006 Share an Integer
ユーザー lotuslotus
提出日時 2020-03-11 13:55:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 881 bytes
コンパイル時間 1,290 ms
コンパイル使用メモリ 166,764 KB
実行使用メモリ 11,396 KB
最終ジャッジ日時 2024-04-27 19:12:41
合計ジャッジ時間 3,380 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
11,200 KB
testcase_01 AC 61 ms
11,192 KB
testcase_02 AC 60 ms
11,208 KB
testcase_03 AC 59 ms
11,272 KB
testcase_04 AC 59 ms
11,308 KB
testcase_05 AC 61 ms
11,244 KB
testcase_06 AC 60 ms
11,192 KB
testcase_07 AC 60 ms
11,396 KB
testcase_08 AC 61 ms
11,192 KB
testcase_09 AC 60 ms
11,268 KB
testcase_10 AC 61 ms
11,296 KB
testcase_11 AC 63 ms
11,192 KB
testcase_12 AC 66 ms
11,380 KB
testcase_13 AC 65 ms
11,340 KB
testcase_14 AC 64 ms
11,304 KB
testcase_15 AC 65 ms
11,268 KB
testcase_16 AC 61 ms
11,256 KB
testcase_17 AC 65 ms
11,388 KB
testcase_18 AC 67 ms
11,220 KB
testcase_19 AC 68 ms
11,224 KB
testcase_20 AC 71 ms
11,344 KB
testcase_21 AC 69 ms
11,268 KB
権限があれば一括ダウンロードができます

ソースコード

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