結果

問題 No.1006 Share an Integer
ユーザー trineutrontrineutron
提出日時 2020-03-08 20:31:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 2,193 ms
コンパイル使用メモリ 196,548 KB
実行使用メモリ 11,192 KB
最終ジャッジ日時 2024-04-25 06:38:36
合計ジャッジ時間 3,443 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 2 ms
5,376 KB
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 25 ms
7,680 KB
testcase_12 AC 47 ms
10,752 KB
testcase_13 AC 48 ms
10,988 KB
testcase_14 AC 54 ms
11,192 KB
testcase_15 AC 41 ms
9,856 KB
testcase_16 AC 19 ms
6,656 KB
testcase_17 AC 27 ms
7,676 KB
testcase_18 AC 41 ms
9,984 KB
testcase_19 AC 39 ms
9,696 KB
testcase_20 AC 42 ms
10,112 KB
testcase_21 AC 47 ms
11,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int x;
    cin >> x;
    vector<int> v(x);
    for (int i = 0; i < x; i++) {
        v.at(i) = i;
    }
    for (int i = 1; i * i < x; i++) {
        v.at(i * i)--;
        for (int j = i * i + i; j < x; j += i) {
            v.at(j) -= 2;
        }
    }
    int d = x;
    for (int i = 1; i < x; i++) {
        d = min(d, abs(v.at(i) - v.at(x - i)));
    }
    for (int i = 1; i < x; i++) {
        if (abs(v.at(i) - v.at(x - i)) == d) {
            cout << i << " " << x - i << endl;
        }
    }
}
0