結果

問題 No.1006 Share an Integer
ユーザー kyort0nkyort0n
提出日時 2020-03-06 21:42:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 995 bytes
コンパイル時間 1,714 ms
コンパイル使用メモリ 165,020 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-04-22 05:40:43
合計ジャッジ時間 4,768 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
11,264 KB
testcase_01 AC 91 ms
11,392 KB
testcase_02 AC 92 ms
11,392 KB
testcase_03 AC 91 ms
11,264 KB
testcase_04 AC 90 ms
11,264 KB
testcase_05 AC 91 ms
11,392 KB
testcase_06 AC 89 ms
11,264 KB
testcase_07 AC 88 ms
11,392 KB
testcase_08 AC 92 ms
11,264 KB
testcase_09 AC 88 ms
11,264 KB
testcase_10 AC 91 ms
11,520 KB
testcase_11 AC 94 ms
11,264 KB
testcase_12 AC 99 ms
11,520 KB
testcase_13 AC 98 ms
11,392 KB
testcase_14 AC 98 ms
11,264 KB
testcase_15 AC 93 ms
11,392 KB
testcase_16 AC 95 ms
11,264 KB
testcase_17 AC 93 ms
11,264 KB
testcase_18 AC 94 ms
11,392 KB
testcase_19 AC 96 ms
11,264 KB
testcase_20 AC 96 ms
11,392 KB
testcase_21 AC 97 ms
11,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
int d[2001000];

int main() {
    for(int i = 1; i <= 2e6; i++) {
        for(int j = i; j <= 2e6; j += i) {
            d[j]++;
        }
    }
    int X;
    cin >> X;
    vector<int> A;
    int val = 1e9;
    for(int i = 1; i < X; i++) {
        int now = abs(i - d[i] - (X - i) + d[X-i]);
        if(chmin(val, now)) {
            A.clear();
        }
        if(val == now) A.push_back(i);
    }
    for(auto tmp : A) {
        cout << tmp << " " << X - tmp << endl;
    }
    return 0;
}
0