結果

問題 No.1006 Share an Integer
ユーザー trineutrontrineutron
提出日時 2020-03-08 20:31:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 2,026 ms
コンパイル使用メモリ 195,108 KB
最終ジャッジ日時 2025-01-09 05:59:58
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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