結果

問題 No.1452 XOR×OR
ユーザー yurukumoyurukumo
提出日時 2021-03-31 15:38:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 4,475 bytes
コンパイル時間 4,402 ms
コンパイル使用メモリ 239,092 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-15 12:18:59
合計ジャッジ時間 5,882 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,384 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,504 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘void dijkstra(WGraph&, vec<long long int>&, ll)’ 内:
main.cpp:123:13: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
  123 |         auto[sum,now]=d.top();d.pop();
      |             ^
main.cpp:125:18: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
  125 |         for(auto&[to,cost]:g[now]){
      |                  ^

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
#define int long long
#define all(n) n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
#define rep(i, s, n) for (int i = s; i < (int)(n); i++)
#define floatset(n) fixed<<setprecision(n)
#define l_b_index(n,x) lower_bound(n.begin(),n.end(),x)-n.begin()
#define u_b_index(n,x) upper_bound(n.begin(),n.end(),x)-n.begin()
#define max_index(n) max_element(n.begin(),n.end())-n.begin()
#define rangeout(x,y,h,w) (x<0||y<0||h-1<x||w-1<y)
#define endl "\n"
#define bitall(bit,n,i) for(int bit=0;bit<(1<<(int)(n));bit++)for(int i=0;i<(int)(n);i++)
#define bitif(bit,i) if(bit&(1<<i))
using namespace std;
using namespace atcoder;
/*
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")*/
template<class Tvec>using vec=vector<Tvec>;
template<class T>using min_queue=priority_queue<T,vector<T>,greater<T>>;
//template<class Tpair,class Tpair2>using pa=pair<Tpair,Tpair2>;
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
using Graph = vector<vector<int>>;
struct Edge1{ll to,cost;};
using WGraph = vec<vec<Edge1>>;
struct BellEdge{ll from,to,cost;};
using BGraph=vec<BellEdge>;
constexpr ll INF = 1e18;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
//素数判定 O(√N)
bool is_prime(ll z){
    if(z<2)return 0;
    bool ok_p = 1;
    ll sz = sqrt(z);
    for(ll i = 2;i <= sz;i++)if(z%i==0){
        ok_p=0;
        break;
    }
    return ok_p;
}
//約数個数 O(√N)
ll divisor_num(ll a) {
  ll ans=0;
  ld a_sqrt = sqrt(a);
  for(int i=1;i<=a_sqrt;i++){
    if(a%i==0){
      if(i==a_sqrt)ans++;
      else ans+=2;
    }
  }
  return ans;
}
//桁和 O(|N|)
ll dig_sum(ll n){
    ll r=0;
    while(n){
        r+=n%10;
        r/=10;
    }
    return r;
}
//約数列挙 O(√N)
vec<ll> divisor(ll n){
    vec<ll>r;ll n_sqrt=sqrt(n);
    for(ll i=1;i<=n_sqrt;i++){
        if(i*i==n)r.push_back(i);
        else if(n%i==0){
            r.push_back(i);
            r.push_back(n/i);
        }
    }
    return r;
}
//素因数分解 O(√N)
map<int,int> prime_fac(ll n){
    map<int,int>r;
    for(int i=2;i*i<=n;i++){
        if(n%i!=0)continue;
        n/=i;
        int cnt=1;
        while(n%i==0){
            n/=i;
            cnt++;
        }
        r[i]=cnt;
    }
    if(n!=1)r[n]=1;
    return r;
}
template<typename T>
bool chmin(T&a,T b){return a>b?a=b,true:false;}
template<typename T>
bool chmax(T&a,T b){return a<b?a=b,true:false;}
//ランレングス圧縮 O(N)
template<typename T1,typename T2>
vec<pair<T1,ll>> rle(T2 s){
    vec<pair<T1,ll>>r;
    ll ss=s.size();
    pair<T1,ll>t={s[0],1};
    rep(i,1,ss){
        if(s[i-1]==s[i])t.second++;
        else{
            r.emplace_back(t);
            t={s[i],1};
        }
    }
    r.emplace_back(t);
    return r;
}
void dijkstra(WGraph&g,vec<ll>&dist,ll s){
    dist[s]=0;
    min_queue<pll> d;
    d.push({0,s});
    while(!d.empty()){
        auto[sum,now]=d.top();d.pop();
        if(dist[now]<sum)continue;
        for(auto&[to,cost]:g[now]){
            if(chmin(dist[to],sum+cost)){
                d.push({dist[to],to});
            }
        }
    }
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
signed main(){
    int N;
    cin>>N;
    if(N==1){
        cout<<1<<endl;
        return 0;
    }
    int ans=0;
    for(int x=1;x*x<=N;x++){
        if(N%x!=0)continue;
        int y=N/x;
        bool ok=1;
        int cnt=1;
        //xがorだと考える
        for(int i=0;i<40;i++){
            if(y&(1LL<<i)){
                if(!(x&(1LL<<i))){
                    ok=0;
                    break;
                }
            }
            if(x&(1LL<<i)){
                if(y&(1LL<<i))
                cnt*=2;
            }
        }
        if(ok){
            ans+=cnt;
          //cout<<x<<endl;
        }
        ok=1;
        cnt=1;
        //yがorだと考える
        for(int i=0;i<40;i++){
            if(x&(1LL<<i)){
                if(!(y&(1LL<<i))){
                  ok=0;
                  break;
                }
            }
            if(y&(1LL<<i)){
                if(x&(1LL<<i))
                cnt*=2;
            }
        }
        if(ok){
            ans+=cnt;
          //cout<<y<<endl;
        }
    }
    cout<<ans/2<<endl;
  //cout<<divisor_num(N)<<endl;
}
0