結果

問題 No.1006 Share an Integer
ユーザー face4face4
提出日時 2020-03-06 21:46:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 802 bytes
コンパイル時間 610 ms
コンパイル使用メモリ 70,644 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2024-04-22 06:20:44
合計ジャッジ時間 2,244 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 48 ms
9,088 KB
testcase_12 AC 94 ms
12,672 KB
testcase_13 AC 98 ms
13,312 KB
testcase_14 AC 98 ms
13,312 KB
testcase_15 AC 78 ms
11,776 KB
testcase_16 AC 36 ms
7,552 KB
testcase_17 AC 49 ms
9,088 KB
testcase_18 AC 81 ms
11,904 KB
testcase_19 AC 77 ms
11,520 KB
testcase_20 AC 85 ms
12,288 KB
testcase_21 AC 97 ms
13,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;

typedef pair<int,int> pii;

int count[2000001] = {};
bool np[2000001] = {};

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) count[i] = 1;
    for(int i = 2; i <= n; i++){
        if(np[i])   continue;
        for(int j = i; j <= n; j += i){
            np[j] = true;
            int tmp = 0, cp = j;
            while(cp%i == 0)    tmp++, cp /= i;
            count[j] *= ++tmp;
        }
    }
    int tmp = 1<<30;
    vector<int> ans;
    for(int i = 1; i <= n; i++){
        int score = abs((i-count[i])-(n-i-count[n-i]));
        if(score > tmp) continue;
        if(score < tmp) ans.clear();
        ans.push_back(i);
        tmp = score;
    }
    for(int i : ans)    cout << i << " " << n-i << endl;
    return 0;
}
0