結果

問題 No.1452 XOR×OR
ユーザー tomoT222
提出日時 2021-03-31 15:25:59
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 2,880 bytes
コンパイル時間 967 ms
コンパイル使用メモリ 97,304 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-02 15:40:24
合計ジャッジ時間 2,015 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<bitset>
#include<functional>
#include <fstream>
//#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
#define puts(x) cout << (x) << "\n"
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const int intINF = 1000000000;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ld pi = 3.141592653589793238;
//const ld EPS = 1e-9;
bool isprime(int p) {
if (p == 1) return false;
for (int i = 2; i < p; i++) {
if (p % i == 0) return false;
}
return true;
}
ll gcd(ll a, ll b) {
if (a < b)swap(a, b);
if (a % b == 0)return b;
return gcd(b, a % b);
}
// : a b
// ax + by = gcd(a, b) (x, y)
//main extGCD(a, b, x, y); x, y
ll extGCD(ll a, ll b, ll& x, ll& y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
ll d = extGCD(b, a % b, y, x);
y -= a / b * x;
return d;
}
ll lcm(ll a, ll b) {
return a / gcd(a, b) * b;
}
ll keta(ll n) {
ll res = 0;
while (n >= 1) {
res += n % 10; n /= 10;
}
return res;
}
ll modpow(ll x, ll y) {
ll res = 1;
while (y) {
if (y % 2) { res *= x; res %= mod; }
x = x * x % mod; y /= 2;
}
return res;
}
ll nCk(ll n, ll k) {
ll a = 1, b = 1;
for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
return a * modpow(b, mod - 2) % mod;
}
//printf("%.10f\n", n);
typedef pair <ll, ll> P;
typedef pair <ld, ll> pp;
ll dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
struct edge { ll to, cost; };
struct status {
ll ima;
ll cost;
ll p;
bool operator<(const status& rhs) const { return cost < rhs.cost; };
bool operator>(const status& rhs) const { return cost > rhs.cost; };
};
signed main() {
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
//cout << fixed << setprecision(15);
//input
vector<ll> v(40);
for (int i = 30; i >= 0; i--) {
v[i] = (ll)pow(2, i);
}
ll n; cin >> n;
ll ans = 0;
for (int a = 1; a <= sqrt(n); a++) {
if (n % a != 0) { continue; }
ll b = n / a;
//a = xor, b = or
ll cnt = a;
bool flag = true; ll kans = 1;
for (int i = 30; i >= 0; i--) {
bool f1 = false, f2 = false;
if (cnt >= v[i]) { f1 = true; cnt -= v[i]; }
if (b >= v[i]) { f2 = true; b -= v[i]; }
if (f1 && !f2) { flag = false; break; }
if (f1 && f2) { kans *= 2; }
}
if (!flag) { continue; }
ans += (kans + 1) / 2;
}
cout << ans << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0