結果

問題 No.1006 Share an Integer
ユーザー rniyarniya
提出日時 2020-03-06 22:16:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 462 bytes
コンパイル時間 1,845 ms
コンパイル使用メモリ 165,768 KB
実行使用メモリ 11,096 KB
最終ジャッジ日時 2024-04-22 08:23:10
合計ジャッジ時間 3,593 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 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 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 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 36 ms
7,520 KB
testcase_12 AC 64 ms
10,516 KB
testcase_13 AC 69 ms
11,008 KB
testcase_14 AC 69 ms
11,096 KB
testcase_15 AC 58 ms
9,920 KB
testcase_16 AC 26 ms
6,528 KB
testcase_17 AC 37 ms
7,680 KB
testcase_18 AC 72 ms
9,900 KB
testcase_19 AC 63 ms
9,588 KB
testcase_20 AC 61 ms
10,220 KB
testcase_21 AC 70 ms
10,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X; cin >> X;
    vector<int> f(X);
    iota(f.begin(),f.end(),0);
    for (int i=1;i<X;++i)
        for (int j=i;j<X;j+=i)
            --f[j];
    int Min=INF;
    for (int i=1;i<=X-i;++i) Min=min(Min,abs(f[i]-f[X-i]));
    for (int i=1;i<X;++i)
        if (abs(f[i]-f[X-i])==Min)
            cout << i << ' ' << X-i << '\n';
}
0