結果

問題 No.1006 Share an Integer
ユーザー 沙耶花沙耶花
提出日時 2020-03-06 21:50:32
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 942 ms / 2,000 ms
コード長 582 bytes
コンパイル時間 3,065 ms
コンパイル使用メモリ 205,204 KB
実行使用メモリ 120,656 KB
最終ジャッジ日時 2024-04-22 07:05:57
合計ジャッジ時間 12,744 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
10,988 KB
testcase_01 AC 69 ms
11,152 KB
testcase_02 AC 68 ms
11,152 KB
testcase_03 AC 66 ms
10,864 KB
testcase_04 AC 65 ms
11,060 KB
testcase_05 AC 85 ms
11,288 KB
testcase_06 AC 66 ms
11,224 KB
testcase_07 AC 67 ms
11,180 KB
testcase_08 AC 66 ms
11,140 KB
testcase_09 AC 66 ms
11,120 KB
testcase_10 AC 67 ms
11,132 KB
testcase_11 AC 551 ms
93,144 KB
testcase_12 AC 927 ms
114,516 KB
testcase_13 AC 939 ms
120,404 KB
testcase_14 AC 939 ms
120,656 KB
testcase_15 AC 826 ms
104,920 KB
testcase_16 AC 395 ms
57,172 KB
testcase_17 AC 539 ms
93,012 KB
testcase_18 AC 812 ms
105,556 KB
testcase_19 AC 803 ms
101,460 KB
testcase_20 AC 861 ms
108,368 KB
testcase_21 AC 942 ms
120,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){

	int X;
	cin>>X;
	
	vector<int> cnt(2000001,0);
	
	for(int i=1;i<=2000000;i++){
		for(int j=i;j<=2000000;j+=i){
			cnt[j]++;
		}
	}
	
	vector<vector<int>> V;
	
	for(int i=1;i<X;i++){
		V.push_back({abs(i-cnt[i]-(X-i-cnt[X-i])),i,X-i});
	}
	
	sort(V.begin(),V.end());
	
	for(int i=0;i<V.size();i++){
		if(i==0||V[i][0]==V[i-1][0]){
			cout<<V[i][1]<<' '<<V[i][2]<<endl;
		}
		else{
			break;
		}
	}
	
    return 0;
}

0