結果

問題 No.1006 Share an Integer
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2020-03-06 21:46:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,982 bytes
コンパイル時間 2,348 ms
コンパイル使用メモリ 202,020 KB
実行使用メモリ 26,336 KB
最終ジャッジ日時 2024-04-22 06:25:20
合計ジャッジ時間 6,227 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int X;
int rest[2010101];
map<int, int> ep[201010];
int d[2010101];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> X;
	rep(i, 1, X + 1) rest[i] = i;
	rep(p, 2, X + 1) for (int x = p; x <= X; x += p) while (rest[x] % p == 0) {
		rest[x] /= p;
		ep[x][p]++;
	}

	rep(i, 1, X + 1) {
		d[i] = 1;
		fore(p, ep[i]) d[i] *= (p.second + 1);
	}

	int mi = inf;
	rep(a, 1, X) {
		int fa = a - d[a];
		int fb = X - a - d[X - a];
		chmin(mi, abs(fa - fb));
	}

	rep(a, 1, X) {
		int fa = a - d[a];
		int fb = X - a - d[X - a];
		if (mi == abs(fa - fb)) {
			printf("%d %d\n", a, X - a);
		}
	}
}





0