結果

問題 No.1006 Share an Integer
ユーザー tempura_pptempura_pp
提出日時 2020-03-06 21:35:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 872 bytes
コンパイル時間 1,193 ms
コンパイル使用メモリ 121,028 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-22 05:17:20
合計ジャッジ時間 2,616 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 37 ms
7,640 KB
testcase_12 AC 69 ms
10,744 KB
testcase_13 AC 75 ms
11,136 KB
testcase_14 AC 78 ms
10,984 KB
testcase_15 AC 63 ms
9,856 KB
testcase_16 AC 27 ms
6,528 KB
testcase_17 AC 39 ms
7,776 KB
testcase_18 AC 61 ms
9,856 KB
testcase_19 AC 59 ms
9,600 KB
testcase_20 AC 64 ms
10,228 KB
testcase_21 AC 71 ms
11,076 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