結果

問題 No.1006 Share an Integer
ユーザー onsen_manjuuuonsen_manjuuu
提出日時 2020-06-14 18:51:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 759 bytes
コンパイル時間 1,764 ms
コンパイル使用メモリ 177,160 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 23:49:54
合計ジャッジ時間 3,258 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long;

const int D = 200;

int divisor(ll n){
    vector<ll> res;
    for(ll i = 1LL; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            ll j = n / i;
            if(i != j)res.push_back(j);
        }
    }
    return res.size();
}

int main()
{
    int x; cin >> x;
    map<int,vector<pair<int,int>>> mp;
    int a = x / 2, b = x - (x / 2);

    for(int i = -D; i <= D; i++) {
        if(a + i <= 0 || b - i <= 0)continue;
        const int A = a + i, B = b - i;
        mp[abs((A - divisor(A)) - (B - divisor(B)))].push_back({A, B});
    }
    for(auto i : mp) {
        for(auto j : i.second)cout << j.first << " " << j.second << endl;
        return 0;
    }
}
0