結果

問題 No.1006 Share an Integer
ユーザー yuboolkuyuboolku
提出日時 2020-03-06 22:47:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,377 bytes
コンパイル時間 1,518 ms
コンパイル使用メモリ 163,584 KB
実行使用メモリ 10,272 KB
最終ジャッジ日時 2024-04-22 09:59:50
合計ジャッジ時間 6,994 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 d (int m) {
    int ans = 0;
    REP(i,1, m + 1) {
        if (m % i == 0) {
            ans++;
        }
    }
    return ans;
}

int main(){

    int X;
    cin >> X;
    int Y = X;
    int m = 0;
    while(Y > 0) {
        m++;
        Y /= 2;
    }

    ll mim = 100101001010101;
    REP(i, X/2 - 3*50, X/2+3*50) {
        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, X/2 - 3*50 , X/2+3*50) {
        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