結果

問題 No.1006 Share an Integer
ユーザー firiexpfiriexp
提出日時 2020-03-06 21:27:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 861 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 96,280 KB
実行使用メモリ 11,196 KB
最終ジャッジ日時 2024-04-27 15:48:44
合計ジャッジ時間 2,285 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 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 1 ms
5,376 KB
testcase_07 AC 1 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,680 KB
testcase_12 AC 76 ms
10,880 KB
testcase_13 AC 84 ms
11,196 KB
testcase_14 AC 83 ms
11,128 KB
testcase_15 AC 66 ms
10,104 KB
testcase_16 AC 27 ms
6,784 KB
testcase_17 AC 37 ms
7,808 KB
testcase_18 AC 67 ms
10,060 KB
testcase_19 AC 59 ms
9,984 KB
testcase_20 AC 71 ms
10,368 KB
testcase_21 AC 80 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <limits>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n+1);
    iota(v.begin(),v.end(), 0);
    for (int i = 1; i <= n; ++i) {
        for (int j = i; j <= n; j += i) {
            v[j]--;
        }
    }
    int ans = INF<int>;
    for (int i = 1; i < n; ++i) {
        ans = min(ans, abs(v[i]-v[n-i]));
    }
    for (int i = 1; i < n; ++i) {
        if(abs(v[i]-v[n-i]) == ans) {
            printf("%d %d\n", i, n-i) ;
        }
    }
    return 0;
}
0