結果
問題 | No.1006 Share an Integer |
ユーザー | 👑 はまやんはまやん |
提出日時 | 2020-03-06 21:49:16 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 310 ms / 2,000 ms |
コード長 | 1,979 bytes |
コンパイル時間 | 2,741 ms |
コンパイル使用メモリ | 201,220 KB |
実行使用メモリ | 113,384 KB |
最終ジャッジ日時 | 2023-08-04 09:09:26 |
合計ジャッジ時間 | 6,917 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
99,412 KB |
testcase_01 | AC | 37 ms
99,424 KB |
testcase_02 | AC | 37 ms
99,692 KB |
testcase_03 | AC | 38 ms
99,412 KB |
testcase_04 | AC | 38 ms
99,584 KB |
testcase_05 | AC | 37 ms
99,424 KB |
testcase_06 | AC | 38 ms
99,652 KB |
testcase_07 | AC | 38 ms
99,716 KB |
testcase_08 | AC | 38 ms
99,648 KB |
testcase_09 | AC | 38 ms
99,424 KB |
testcase_10 | AC | 37 ms
99,580 KB |
testcase_11 | AC | 158 ms
108,372 KB |
testcase_12 | AC | 274 ms
113,140 KB |
testcase_13 | AC | 310 ms
113,384 KB |
testcase_14 | AC | 295 ms
113,372 KB |
testcase_15 | AC | 246 ms
112,448 KB |
testcase_16 | AC | 121 ms
106,008 KB |
testcase_17 | AC | 157 ms
108,520 KB |
testcase_18 | AC | 255 ms
112,452 KB |
testcase_19 | AC | 233 ms
112,276 KB |
testcase_20 | AC | 266 ms
112,484 KB |
testcase_21 | AC | 305 ms
113,352 KB |
ソースコード
#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(i, 1, X + 1) d[i] = 1; rep(p, 2, X + 1) for (int x = p; x <= X; x += p) if(rest[x] % p == 0) { int cnt = 0; while (rest[x] % p == 0) rest[x] /= p, cnt++; d[x] *= cnt + 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); } } }