結果

問題 No.1006 Share an Integer
ユーザー 夜
提出日時 2020-11-12 01:07:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 986 bytes
コンパイル時間 744 ms
コンパイル使用メモリ 92,716 KB
実行使用メモリ 13,336 KB
最終ジャッジ日時 2023-09-30 00:59:32
合計ジャッジ時間 2,542 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 44 ms
10,904 KB
testcase_12 AC 76 ms
12,552 KB
testcase_13 AC 81 ms
13,100 KB
testcase_14 AC 81 ms
13,160 KB
testcase_15 AC 68 ms
11,836 KB
testcase_16 AC 33 ms
8,328 KB
testcase_17 AC 45 ms
10,696 KB
testcase_18 AC 69 ms
11,968 KB
testcase_19 AC 66 ms
11,412 KB
testcase_20 AC 70 ms
12,084 KB
testcase_21 AC 80 ms
13,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int co[2000020];
bool bo[2000020] = { false };
int main() {
	int x;
	cin >> x;
	for (int i = 1; i <= x; i++) {
		co[i] = 1;
	}
	for (int i = 2; i <= x; i++) {
		if (!bo[i]) {
			for (int j = i; j <= x; j += i) {
				bo[j] = true;
				int j1 = j, co1 = 1;
				while (j1 % i == 0) {
					j1 /= i;
					co1++;
				}
				co[j] *= co1;
			}
		}
	}
	int ans = 1000000007;
	for (int i = 1; i < x; i++) {
		if (ans > abs((i - co[i]) - (x - i - co[x - i]))) {
			ans = abs((i - co[i]) - (x - i - co[x - i]));
		}
	}
	for (int i = 1; i < x; i++) {
		if (ans == abs((i - co[i]) - (x - i - co[x - i]))) {
			cout << i << " " << x - i << endl;
		}
	}
}
0