結果

問題 No.1006 Share an Integer
ユーザー tempura_pptempura_pp
提出日時 2020-03-06 21:35:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 872 bytes
コンパイル時間 1,293 ms
コンパイル使用メモリ 121,696 KB
実行使用メモリ 10,864 KB
最終ジャッジ日時 2023-08-04 07:23:24
合計ジャッジ時間 3,008 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 36 ms
7,528 KB
testcase_12 AC 86 ms
10,376 KB
testcase_13 AC 89 ms
10,760 KB
testcase_14 AC 88 ms
10,752 KB
testcase_15 AC 69 ms
9,836 KB
testcase_16 AC 28 ms
6,204 KB
testcase_17 AC 39 ms
7,504 KB
testcase_18 AC 74 ms
9,824 KB
testcase_19 AC 61 ms
9,436 KB
testcase_20 AC 76 ms
9,976 KB
testcase_21 AC 89 ms
10,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;


int cnt[2][2];
int main(){
	int n;
	cin>>n;
	vector<int> ans(n+1);
	rep(i,n)ans[i+1]=i+1;
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j+=i)ans[j]--;
	}
	vector<int> ret;
	int res = inf;
	for(int i=1;i<n;i++){
		int t = abs(ans[i]-ans[n-i]);
		if(t<res){
			ret.clear();
			res = t;
		}
		if(t==res)ret.push_back(i);
	}
	for(auto e:ret){
		cout<<e<<" "<<n-e<<endl;
	}
	return 0;
}
0