結果

問題 No.1006 Share an Integer
ユーザー 👑 tatyamtatyam
提出日時 2020-03-03 02:49:05
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 523 bytes
コンパイル時間 1,952 ms
コンパイル使用メモリ 198,568 KB
実行使用メモリ 11,464 KB
最終ジャッジ日時 2023-08-04 01:01:45
合計ジャッジ時間 3,559 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 34 ms
7,784 KB
testcase_12 AC 61 ms
10,800 KB
testcase_13 AC 66 ms
11,156 KB
testcase_14 AC 65 ms
11,160 KB
testcase_15 AC 62 ms
10,044 KB
testcase_16 AC 24 ms
6,652 KB
testcase_17 AC 36 ms
7,832 KB
testcase_18 AC 68 ms
10,092 KB
testcase_19 AC 59 ms
9,792 KB
testcase_20 AC 69 ms
10,296 KB
testcase_21 AC 65 ms
11,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmin(T& a, const T& b){ if(a > b){ a = b; return 1; } return 0; }

int main(){
    int x;
    cin >> x;
    int divisor[x];
    iota(divisor, divisor + x, 0);
    for(int i = 1; i < x; i++) for(int j = i; j < x; j += i) divisor[j]--;
    int min = 0x3fffffff;
    for(int i = 1; i <= x / 2; i++) chmin(min, abs(divisor[i] - divisor[x - i]));
    for(int i = 1; i < x; i++) if(abs(divisor[i] - divisor[x - i]) == min) cout << i << ' ' << x - i << endl;
}
0