結果

問題 No.1006 Share an Integer
ユーザー ForestedForested
提出日時 2020-05-26 13:50:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 719 bytes
コンパイル時間 827 ms
コンパイル使用メモリ 94,772 KB
実行使用メモリ 11,076 KB
最終ジャッジ日時 2024-04-21 04:16:19
合計ジャッジ時間 2,392 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 37 ms
7,552 KB
testcase_12 AC 77 ms
10,496 KB
testcase_13 AC 85 ms
10,880 KB
testcase_14 AC 82 ms
11,008 KB
testcase_15 AC 67 ms
9,984 KB
testcase_16 AC 27 ms
6,656 KB
testcase_17 AC 38 ms
7,680 KB
testcase_18 AC 69 ms
9,984 KB
testcase_19 AC 62 ms
9,600 KB
testcase_20 AC 73 ms
10,112 KB
testcase_21 AC 83 ms
11,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    int X;
    cin >> X;
    
    vector<int> d(X + 1, 0);
    for (int i = 1; i <= X; ++i) {
        for (int j = i; j <= X; j += i) ++d[j];
    }
    int ans = 1e9;
    for (int i = 1; i <= X; ++i) {
        ans = min(ans, abs((i - d[i]) - (X - i - d[X - i])));
    }
    for (int i = 1; i <= X; ++i) {
        if (abs((i - d[i]) - (X - i - d[X - i])) == ans) cout << i << " " << X - i << "\n";
    }
    return 0;
}
0