結果

問題 No.1006 Share an Integer
ユーザー mdstoymdstoy
提出日時 2020-03-06 22:13:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,089 bytes
コンパイル時間 1,912 ms
コンパイル使用メモリ 173,388 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-22 08:13:37
合計ジャッジ時間 4,831 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 WA -
testcase_04 AC 2 ms
6,944 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 3 ms
6,944 KB
testcase_11 AC 170 ms
6,940 KB
testcase_12 AC 218 ms
6,940 KB
testcase_13 AC 225 ms
6,940 KB
testcase_14 AC 224 ms
6,940 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 209 ms
6,944 KB
testcase_19 AC 205 ms
6,944 KB
testcase_20 AC 214 ms
6,940 KB
testcase_21 AC 224 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

vector<ll> divisors(ll n) {
    vector<ll> v;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            v.push_back(i);
            if (i * i != n) {
                v.push_back(n / i);
            }
        }
    }
    return v;
}

void solve() {
    int n;
    cin >> n;
    vector<tuple<int, int, int>> ans;
    int mn = INF;
    auto f = [&](int x) {return x - sz(divisors(x));};
    FOR(i, max(1, n / 2 - 10000) , n / 2 + 1) {
        int d = abs(f(i) - f(n - i));
        chmin(mn, d);
        ans.emplace_back(i, n - i, d);
    }
    for (auto t : ans) {
        if (get<2>(t) == mn) cout << get<0>(t) << " " << get<1>(t) << endl;
    }
    REV(ans);
    for (auto t : ans) {
        if (get<2>(t) == mn) cout << get<1>(t) << " " << get<0>(t) << endl;
    }

}
0