結果

問題 No.1006 Share an Integer
ユーザー 東前頭十一枚目東前頭十一枚目
提出日時 2020-03-17 21:25:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 553 bytes
コンパイル時間 1,539 ms
コンパイル使用メモリ 168,464 KB
実行使用メモリ 11,228 KB
最終ジャッジ日時 2023-08-20 18:56:58
合計ジャッジ時間 3,445 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 38 ms
9,668 KB
testcase_12 AC 86 ms
10,920 KB
testcase_13 AC 94 ms
11,228 KB
testcase_14 AC 92 ms
11,180 KB
testcase_15 AC 72 ms
10,256 KB
testcase_16 AC 26 ms
7,424 KB
testcase_17 AC 37 ms
9,504 KB
testcase_18 AC 72 ms
10,116 KB
testcase_19 AC 63 ms
9,792 KB
testcase_20 AC 76 ms
10,296 KB
testcase_21 AC 92 ms
11,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int f[2000010];
int main() {
	int x; cin >> x;
	for(int i = 1; i <= x; ++i) {
		f[i] = i;
	}
	for(int i = 1; i <= x; ++i) {
		for(int j = i; j <= x; j += i) {
			--f[j];
		}
	}
	vector<pair<int, int>> ans;
	int mini = x;
	for(int i = 1; i < x; ++i) {
		int s = abs(f[i] - f[x - i]);
		if(s < mini) {
			mini = s;
			ans.clear();
			ans.emplace_back(i, x - i);
		} else if(s == mini) {
			ans.emplace_back(i, x - i);
		}
	}
	for(auto& e : ans) {
		cout << e.first << " " << e.second << '\n';
	}
	return 0;
}
0