結果

問題 No.1006 Share an Integer
ユーザー minatominato
提出日時 2020-03-06 21:42:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 1,303 bytes
コンパイル時間 2,264 ms
コンパイル使用メモリ 179,052 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-22 05:37:22
合計ジャッジ時間 3,858 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 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 1 ms
5,376 KB
testcase_11 AC 40 ms
7,680 KB
testcase_12 AC 82 ms
10,624 KB
testcase_13 AC 98 ms
10,880 KB
testcase_14 AC 91 ms
10,880 KB
testcase_15 AC 73 ms
10,112 KB
testcase_16 AC 28 ms
6,528 KB
testcase_17 AC 41 ms
7,680 KB
testcase_18 AC 75 ms
9,856 KB
testcase_19 AC 67 ms
9,600 KB
testcase_20 AC 79 ms
10,112 KB
testcase_21 AC 91 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int X; cin >> X;
    vector<int> A(X+1);
    iota(all(A),0);
    for (int i = 1; i <= X; ++i) {
        for (int j = 1; j*i <=X; ++j) {
            A[i*j]--;
        }
    }

    int val = 1e9;
    map<int, int> dic;
    for (int i = 1; i < X; ++i) {
        if (val > abs(A[i] - A[X-i])) {
            val = abs(A[i] - A[X-i]);
            dic.clear();
            dic.emplace(i,X-i);
        } else if (val==abs(A[i] - A[X-i])) {
            dic.emplace(i,X-i);
        }
    }

    for (auto i : dic) {
        cout << i.first << " " << i.second << ln;
    }
}
0