結果

問題 No.1006 Share an Integer
ユーザー 東前頭十一枚目東前頭十一枚目
提出日時 2020-03-17 21:25:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 553 bytes
コンパイル時間 1,371 ms
コンパイル使用メモリ 170,500 KB
実行使用メモリ 11,304 KB
最終ジャッジ日時 2024-05-08 01:23:46
合計ジャッジ時間 2,672 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 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 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 39 ms
7,808 KB
testcase_12 AC 65 ms
10,880 KB
testcase_13 AC 67 ms
11,264 KB
testcase_14 AC 67 ms
11,264 KB
testcase_15 AC 58 ms
10,112 KB
testcase_16 AC 26 ms
6,912 KB
testcase_17 AC 37 ms
7,936 KB
testcase_18 AC 59 ms
10,240 KB
testcase_19 AC 56 ms
9,984 KB
testcase_20 AC 60 ms
10,496 KB
testcase_21 AC 68 ms
11,304 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