結果

問題 No.1006 Share an Integer
ユーザー yuboolkuyuboolku
提出日時 2020-03-07 00:00:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 1,346 bytes
コンパイル時間 1,756 ms
コンパイル使用メモリ 165,292 KB
実行使用メモリ 11,516 KB
最終ジャッジ日時 2024-04-22 10:59:31
合計ジャッジ時間 4,381 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
11,444 KB
testcase_01 AC 66 ms
11,356 KB
testcase_02 AC 65 ms
11,480 KB
testcase_03 AC 63 ms
11,452 KB
testcase_04 AC 67 ms
11,236 KB
testcase_05 AC 66 ms
11,488 KB
testcase_06 AC 65 ms
11,516 KB
testcase_07 AC 65 ms
11,264 KB
testcase_08 AC 65 ms
11,424 KB
testcase_09 AC 65 ms
11,364 KB
testcase_10 AC 66 ms
11,248 KB
testcase_11 AC 68 ms
11,328 KB
testcase_12 AC 72 ms
11,332 KB
testcase_13 AC 70 ms
11,404 KB
testcase_14 AC 71 ms
11,404 KB
testcase_15 AC 69 ms
11,332 KB
testcase_16 AC 69 ms
11,424 KB
testcase_17 AC 69 ms
11,392 KB
testcase_18 AC 71 ms
11,268 KB
testcase_19 AC 69 ms
11,360 KB
testcase_20 AC 70 ms
11,464 KB
testcase_21 AC 72 ms
11,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;



int main(){
    int d[2001000];

    for(int i = 1; i <= 2e6; i++) {
        for(int j = i; j <= 2e6; j += i) {
            d[j]++;
        }
    }
    int X;
    cin >> X;
    int Y = X;
    int m = 0;
    while(Y > 0) {
        m++;
        Y /= 2;
    }

    ll mim = 100101001010101;
    REP(i, 1, X) {
        int j = X - i;
        if (i > 0 && j > 0) {
//            cout << d(i) << endl;
            ll res = i - j - d[i] + d[j];
//            cout << abs(res) << endl;
            chmin(mim, abs(res));
        }

    }

    REP(i, 1, X) {
        int j = X - i;
        if (i > 0 && j > 0) {
            ll res = i - j - d[i] + d[j];
//            cout << i << " " << abs(res) << endl;
            if (mim == abs(res)) {
                cout << i << " " << j << endl;
            }
        }
    }




}
0