結果

問題 No.1006 Share an Integer
ユーザー 東前頭十一枚目東前頭十一枚目
提出日時 2020-03-17 21:24:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 554 bytes
コンパイル時間 1,545 ms
コンパイル使用メモリ 167,360 KB
実行使用メモリ 11,256 KB
最終ジャッジ日時 2023-08-20 18:56:54
合計ジャッジ時間 3,285 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 34 ms
9,540 KB
testcase_12 AC 75 ms
10,848 KB
testcase_13 AC 81 ms
11,152 KB
testcase_14 AC 83 ms
11,152 KB
testcase_15 AC 64 ms
10,036 KB
testcase_16 AC 25 ms
7,548 KB
testcase_17 AC 36 ms
9,544 KB
testcase_18 AC 65 ms
10,088 KB
testcase_19 AC 57 ms
9,916 KB
testcase_20 AC 69 ms
10,340 KB
testcase_21 AC 81 ms
11,256 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