結果

問題 No.1006 Share an Integer
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2020-03-06 21:47:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,983 bytes
コンパイル時間 2,246 ms
コンパイル使用メモリ 201,232 KB
実行使用メモリ 385,920 KB
最終ジャッジ日時 2024-04-22 06:34:02
合計ジャッジ時間 27,840 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
98,048 KB
testcase_01 AC 53 ms
97,792 KB
testcase_02 AC 54 ms
97,920 KB
testcase_03 AC 51 ms
98,048 KB
testcase_04 AC 50 ms
98,048 KB
testcase_05 AC 77 ms
97,920 KB
testcase_06 AC 41 ms
98,048 KB
testcase_07 AC 40 ms
98,112 KB
testcase_08 AC 40 ms
98,176 KB
testcase_09 AC 41 ms
98,048 KB
testcase_10 AC 41 ms
98,176 KB
testcase_11 AC 1,351 ms
256,640 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 AC 1,026 ms
217,088 KB
testcase_17 AC 1,439 ms
260,864 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
権限があれば一括ダウンロードができます

ソースコード

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[2010101];
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