結果

問題 No.1006 Share an Integer
ユーザー tkmst201tkmst201
提出日時 2021-01-19 10:49:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 965 bytes
コンパイル時間 2,105 ms
コンパイル使用メモリ 204,824 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-05-09 13:35:36
合計ジャッジ時間 3,790 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 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 AC 38 ms
7,680 KB
testcase_12 AC 82 ms
10,880 KB
testcase_13 AC 86 ms
11,228 KB
testcase_14 AC 86 ms
11,160 KB
testcase_15 AC 68 ms
9,996 KB
testcase_16 AC 27 ms
6,784 KB
testcase_17 AC 37 ms
7,784 KB
testcase_18 AC 68 ms
10,228 KB
testcase_19 AC 62 ms
9,856 KB
testcase_20 AC 75 ms
10,244 KB
testcase_21 AC 87 ms
11,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = false;
//---------------------------------//

int main() {
	int X;
	cin >> X;
	vector<int> f(X + 1);
	iota(ALL(f), 0);
	FOR(i, 1, X + 1) for (int j = i; j <= X; j += i) --f[j];
	
	int mn = INF;
	vector<int> ans;
	FOR(i, 1, X) {
		const int cur = abs(f[i] - f[X - i]);
		if (mn < cur) continue;
		if (chmin(mn, cur)) ans.clear();
		ans.emplace_back(i);
	}
	for (int i : ans) printf("%d %d\n", i, X - i);
}
0