結果

問題 No.1006 Share an Integer
ユーザー forest3forest3
提出日時 2020-07-15 09:19:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 598 bytes
コンパイル時間 1,799 ms
コンパイル使用メモリ 176,592 KB
実行使用メモリ 23,240 KB
最終ジャッジ日時 2024-05-01 05:15:10
合計ジャッジ時間 5,707 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,760 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 WA -
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
	int X;
	cin >> X;

	auto f = []( int N ) -> int
	{
		int d = 0;
		for( int x = 1; x * x <= N; x++ ) {
			if( N % x == 0 ) {
				d++;
				if( N / x != x ) d++;
			}
		}
		return N - d;
	};


	vector<tuple<int, int, int>> tp;
	for( int A = 1; A < X; A++ ) {
		int B = X - A;
		int a = f( A );
		int b = f( B );
		tp.push_back( make_tuple( abs( a - b ), A, B ) );
	}
	sort( tp.begin(), tp.end() );
	int mi = get<0>( tp[0] );

	for( int i = 0; get<0>( tp[i] ) == mi; i++ ) {
		cout << get<1>( tp[i] ) << " " << get<2>( tp[i] ) << endl;
	}
}
0