結果

問題 No.1452 XOR×OR
ユーザー souma987souma987
提出日時 2021-03-31 15:09:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,999 bytes
コンパイル時間 3,729 ms
コンパイル使用メモリ 226,932 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-15 12:17:46
合計ジャッジ時間 5,059 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,384 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// Created at 2021/03/31 14:00
// {TODO}WA, {TODO}min, {TODO}diff
// goal: {TODO}min
#include <bits/stdc++.h>
#include <atcoder/all>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define overload4(_1,_2,_3,_4,name,...) name
#define rep(i, n) for (lint i = 0, i##_lim = n; i < i##_lim; i++)
#define rep2(i, n) for (lint i = 1, i##_lim = n; i <= i##_lim; i++)
#define rep3(i, s, e) for (lint i = s, i##_lim = e; i < i##_lim; i++)
#define all(i) (i).begin(), (i).end()
#define print1(s) cout << (s) << '\n';
#define print2(s1, s2) cout << (s1) << ' ' << (s2) << '\n';
#define print3(s1, s2, s3) cout << (s1) << ' ' << (s2) << ' ' << (s3) << '\n';
#define print4(s1, s2, s3, s4) cout << (s1) << ' ' << (s2) << ' ' << (s3) << ' ' << (s4) << '\n';
#define print(...) overload4(__VA_ARGS__, print4, print3, print2, print1)(__VA_ARGS__)
using namespace std;
using namespace atcoder;
using lint = long long;
using ld = long double;
using pi = pair<int, int>;
using pl = pair<lint, lint>;
using vi = vector<int>;
using vl = vector<lint>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using qi = queue<int>;
using ql = queue<lint>;
using qpi = queue<pi>;
constexpr int INF = 1 << 30;
constexpr lint INFl = 1LL << 62;

template<class T, class U>
istream &operator>>(istream &is, pair<T, U> &pair) {
    is >> pair.first >> pair.second;
    return is;
}

template<class T, class U>
ostream &operator<<(ostream &os, pair <T, U> &pair) {
    os << pair.first << ' ' << pair.second;
    return os;
}

template<class T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &v : vec) is >> v;
    return is;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << '[';
    for (auto v : vec) os << v << ", ";
    os << ']';
    return os;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (b > a) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

lint check(lint c, lint d) {
    lint rtn = 1;
    while (c || d) {
        if ((c & 1) && (d & 1)) {
            rtn *= 2;
        }
        if ((c & 1) && !(d & 1)) {
            return 0;
        }
        c >>= 1;
        d >>= 1;
    }
    if (rtn == 1) return 1;
    else return rtn / 2;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//    cout << fixed << setprecision(15);
    // 二分探索
    // 全探索
    // 動的計画法
    // 逆からたどる
    // ネットワークフロー
    // 二部マッチング
    // ggrks
    /*----------------------------------------------------*/
    int n; cin >> n;

    lint ans = 0;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ans += check(i, n / i);
            if (n / i != i) ans += check(n / i, i);
        }
    }

    print(ans)
    // 最大値は?
}
0