結果

問題 No.2406 Difference of Coordinate Squared
ユーザー eQeeQe
提出日時 2023-08-05 00:52:02
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 12,643 bytes
コンパイル時間 6,302 ms
コンパイル使用メモリ 335,592 KB
実行使用メモリ 15,360 KB
最終ジャッジ日時 2024-05-05 01:42:53
合計ジャッジ時間 8,375 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 43 ms
15,104 KB
testcase_02 AC 44 ms
15,360 KB
testcase_03 AC 55 ms
14,976 KB
testcase_04 AC 44 ms
15,232 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 22 ms
8,832 KB
testcase_07 AC 18 ms
7,680 KB
testcase_08 AC 28 ms
11,008 KB
testcase_09 AC 30 ms
11,520 KB
testcase_10 AC 39 ms
14,336 KB
testcase_11 AC 33 ms
12,288 KB
testcase_12 AC 37 ms
13,312 KB
testcase_13 AC 37 ms
12,928 KB
testcase_14 AC 39 ms
13,696 KB
testcase_15 AC 42 ms
14,592 KB
testcase_16 AC 27 ms
10,368 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 8 ms
5,376 KB
testcase_19 AC 37 ms
13,824 KB
testcase_20 AC 40 ms
14,336 KB
testcase_21 AC 23 ms
9,600 KB
testcase_22 AC 17 ms
7,040 KB
testcase_23 AC 41 ms
14,848 KB
testcase_24 AC 11 ms
6,016 KB
testcase_25 AC 4 ms
5,376 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 3 ms
5,632 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 3 ms
6,400 KB
testcase_31 AC 5 ms
7,936 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 5 ms
7,936 KB
testcase_35 AC 6 ms
9,984 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 7 ms
10,112 KB
testcase_38 AC 6 ms
8,576 KB
testcase_39 AC 3 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 7 ms
10,240 KB
testcase_43 AC 7 ms
10,240 KB
testcase_44 AC 4 ms
6,272 KB
testcase_45 AC 3 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 6 ms
9,344 KB
testcase_48 AC 3 ms
5,376 KB
testcase_49 AC 3 ms
5,376 KB
testcase_50 AC 2 ms
5,376 KB
testcase_51 AC 5 ms
7,168 KB
testcase_52 AC 3 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 AC 6 ms
8,704 KB
testcase_55 AC 2 ms
5,376 KB
testcase_56 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace atcoder;
template<typename V>struct ve;
using ml=modint;using m1=ve<ml>;
auto&operator>>(std::istream&i,ml&x){long long t;i>>t;x=t;return i;}
auto&operator<<(std::ostream&o,const ml&x){return o<<x.val();}
#define ep(...) emplace(__VA_ARGS__)
#define eb(...) emplace_back(__VA_ARGS__)
#define all(a) begin(a),end(a)
#define wh(...) while(__VA_ARGS__)
#define ef(...) else if(__VA_ARGS__)
#define done(...) rr pp(__VA_ARGS__)
#define RD(T,...) T __VA_ARGS__;li(__VA_ARGS__)
#define LL(...) RD(ll,__VA_ARGS__)
#define ST(...) RD(str,__VA_ARGS__)
#define UL(n,...) u1 __VA_ARGS__;setsize({n},__VA_ARGS__);li(__VA_ARGS__)
#define UV(n,...) u1 __VA_ARGS__;setsize({n},__VA_ARGS__);vi(__VA_ARGS__)
#define U2(n,m,...) u2 __VA_ARGS__;setsize({n,m},__VA_ARGS__);li(__VA_ARGS__)
#define VE(a,...) au a=vec(__VA_ARGS__)
#define FE(v,e,...) for(au&&__VA_OPT__([)e __VA_OPT__(,__VA_ARGS__]):v)
#define FO(n) for(ll jo(i,__LINE__)=n;jo(i,__LINE__)-->0;)
#define FOR(i,...) for(au[i,i##O,i##E]=rng(0,__VA_ARGS__);i<i##O;i+=i##E)
#define fe(v,...) FE(v,__VA_ARGS__)
#define fo(i,...) FO##__VA_OPT__(R)(i __VA_OPT__(,__VA_ARGS__))
#define of(i,...) for(au[i##O,i,i##E]=rng(1,__VA_ARGS__);i>=i##O;i-=i##E)
#define fs(i,...) for(ll i##E=__VA_ARGS__,i=i##E;i;--i&=i##E)
#define debug(...) pp(#__VA_ARGS__,__VA_ARGS__)
#define JO(a,b) a##b
#define jo(a,b) JO(a,b)
#define I(...) template<__VA_ARGS__>
#define J typename
#define O operator
#define au auto
#define cs const
#define ifc if constexpr
#define rr return
#define uu using
uu std::cin,std::cout,std::begin,std::end,std::rbegin,std::get;
uu std::swap,std::move,std::gcd,std::lcm,std::abs,std::prev,std::next;
uu std::deque,std::tuple,std::array,std::bitset,std::minmax;
uu vo=void;uu bo=bool;
vo solve();
I(J A,J B)constexpr bo same=std::is_same_v<A,B>;
I(bo b,J A,J B)uu ift=std::conditional_t<b,A,B>;
uu is=std::istream;uu os=std::ostream;
uu dd=long double;uu ll=long long;uu ull=unsigned long long;
uu lll=__int128_t;uu ulll=__uint128_t;uu str=std::string;
dd ee=1e-12,pi=acosl(-1);
ll oo=3e18,i998244353=998244353,i1000000007=1000000007;
array<ll,8>dx{-1,0,1,0,-1,1,1,-1},dy{0,-1,0,1,-1,-1,1,1};
char sp=32,nl=10;
I(J T,J U=T)uu map=std::map<T,U>;
I(J T,J U=T)uu umap=std::unordered_map<T,U>;
I(J T)uu qmax=std::priority_queue<T>;
I(J T)uu qmin=std::priority_queue<T,std::vector<T>,std::greater<>>;
I(J T,ll n)au TP(){ifc(n)rr tuple_cat(tuple(T()),TP<T,n-1>());else rr tuple();}
I(J T,ll n)uu tp=decltype(TP<T,n>());I(ll n)uu tpl=tp<ll,n>;
au rng(bo s,ll a,ll b=oo,ll c=1){if(b==oo)b=a,a=0;rr tuple{a,b-s,c};}

ll rnd(ll l=oo,ll r=oo){static ull a=76,b=53,c=20,d=41;
  ull t=a^(a<<11);a=b,b=c,c=d,d=(d^(d>>19))^(t^(t>>8));
  rr r!=oo?d%(r-l)+l:l!=oo?d%l:d;
}
bo odd(ll x){rr x&1;}
bo eve(ll x){rr~x&1;}
ll pwm1(ll x){rr 1-2*(x&1);}
I(J T)T zz(T x){rr x<0?-x:x;}
I(J T)ll len(cs T&a){rr a.size();}

struct edg{ll t,w;edg(){}edg(ll t,ll w=1):t(t),w(w){}};

I(J A,J B=A)struct cp{
  A a={};B b={};
  cp(){}
  cp(A a,B b):a(a),b(b){}
  cp(std::pair<A,B>p):a(p.first),b(p.second){}
  cp O-()cs{rr cp(-a,-b);}
  cp&O+=(cs cp&c){a+=c.a,b+=c.b;rr*this;}cp O+(cs cp&c)cs{rr cp{*this}+=c;}
  cp&O-=(cs cp&c){a-=c.a,b-=c.b;rr*this;}cp O-(cs cp&c)cs{rr cp{*this}-=c;}
  bo O==(cs cp&c)cs{rr a==c.a&&b==c.b;}
  bo O<(cs cp&c)cs{rr a!=c.a?a<c.a:b<c.b;}
  bo O>(cs cp&c)cs{rr a!=c.a?a>c.a:b>c.b;}

  I(J T)cp&O+=(cs T&x){a+=x,b+=x;rr*this;}I(J T)cp O+(cs T&x)cs{rr cp{*this}+=x;}
  I(J T)cp&O-=(cs T&x){a-=x;b-=x;rr*this;}I(J T)cp O-(cs T&x)cs{rr cp{*this}-=x;}
  I(J T)cp&O*=(cs T&x){a*=x;b*=x;rr*this;}I(J T)cp O*(cs T&x)cs{rr cp{*this}*=x;}
  au abs()cs{rr zz(a)+zz(b);}au abs(cs cp&c)cs{rr(*this-c).abs();}
};uu cl=cp<ll>;
I(J A,J B=A,J C=A)struct tr{
  A a={};B b={};C c={};
  tr(){}
  tr(A a,B b,C c):a(a),b(b),c(c){}
  bo O==(cs tr&t)cs{rr a==t.a&&b==t.b&&c==t.c;}
  bo O<(cs tr&t)cs{rr a!=t.a?a<t.a:b!=t.b?b<t.b:c<t.c;}
  bo O>(cs tr&t)cs{rr a!=t.a?a>t.a:b!=t.b?b>t.b:c>t.c;}

};uu tl=tr<ll>;

I(J V)struct ve;
I(J V)constexpr bo isv=0;
I(J V)constexpr bo isv<ve<V>> =1;
I(J V)constexpr bo isv<std::vector<V>> =1;
I(J V)au raw_val(V){ifc(isv<V>)rr raw_val(V(1)[0]);else rr V();}

I(J V)struct ve:std::vector<V>{
  uu std::vector<V>::vector;
  uu raw_type=decltype(raw_val(V()));
  I(J U)ve(cs std::vector<U>&v={}){fe(v,e)this->eb(e);}

  au&O+=(cs ve&u){au&v=*this;fo(i,len(v))v[i]+=u[i];rr v;}
  au&O-=(cs ve&u){au&v=*this;fo(i,len(v))v[i]-=u[i];rr v;}
  au&O^=(cs ve&u){fe(u,e)this->eb(e);rr*this;}
  au&O+=(cs raw_type&c){au&v=*this;fe(v,e)e+=c;rr v;}
  au&O-=(cs raw_type&c){au&v=*this;fe(v,e)e-=c;rr v;}
  au&O*=(cs raw_type&c){au&v=*this;fe(v,e)e*=c;rr v;}
  I(size_t n)au&O+=(cs bitset<n>&a){fo(i,len(*this))(*this)[i]+=a[i];rr*this;}
  I(size_t n)au&O-=(cs bitset<n>&a){fo(i,len(*this))(*this)[i]-=a[i];rr*this;}

  au O+(cs ve&u){rr ve(*this)+=u;}
  au O-(cs ve&u){rr ve(*this)-=u;}
  au O^(cs ve&u){rr ve(*this)^=u;}
  au O+(cs raw_type&c){rr ve(*this)+=c;}au&O++(){rr*this+=1;}
  au O-(cs raw_type&c){rr ve(*this)-=c;}au&O--(){rr*this-=1;}
  au O*(cs raw_type&c){rr ve(*this)*=c;}au O-(){rr ve(*this)*=-1;}

  I(bo f(raw_type&,cs raw_type&))au scan(){
    cp<raw_type,bo>r;
    fe(*this,e)ifc(!isv<V>)r.b?f(r.a,e),r:r={e,1};ef(au t=e.template scan<f>();t.b)r.b?f(r.a,t.a),r:r=t;rr r;
  }

  au de(cs str&b="a"){
    ift<isv<V>,ve<str>,str>r;
    ifc(isv<V>)fe(*this,e)r.eb(e.de(b));
    else fe(*this,e)r+=len(b)==1?e+b[0]:0<=e&&e<len(b)?b[e]:'|';
    rr r;
  }
};
I(J T=ll,ll n,ll i=0)au vec(cs ll(&s)[n],T x={}){ifc(n==i+1)rr ve<T>(s[i],x);else{au X=vec<T,n,i+1>(s,x);rr ve<decltype(X)>(s[i],X);}}
I(ll n,J...A)vo setsize(cs ll(&l)[n],A&...a){((a=vec(l,raw_val(a))),...);}
I(J T)uu V1=ve<T>;uu u1=V1<ll>;I(J T)uu V2=V1<V1<T>>;uu u2=V2<ll>;
uu strs=V1<str>;uu gra=V2<edg>;uu cls=V1<cl>;uu tls=V1<tl>;

I(J T)T&srt(T&a){sort(all(a));rr a;}
I(J T)decltype(au)bg(T&a){rr*begin(a);}
I(J T)decltype(au)rb(T&a){rr*rbegin(a);}
I(J T)au pot(T&a){au r=a.top();a.pop();rr r;}
I(J T)au pof(T&a){au r=bg(a);a.pop_front();rr r;}

struct io{io(){cin.tie(0)->sync_with_stdio(0);
  cout<<std::fixed<<std::setprecision(15);std::cerr<<nl;}}io;
os&O<<(os&o,cs ulll&x){rr(x<10?o:o<<x/10)<<ll(x%10);}
os&O<<(os&o,cs lll&x){rr o<<str(x<0,'-')<<ulll(zz(x));}
os&O<<(os&o,cs edg&e){rr o<<e.t<<sp<<e.w;}
I(J T)os&O<<(os&o,cs deque<T>&q){fe(q,e)o<<e<<sp;rr o;}
I(J T)os&O<<(os&o,qmax<T>q){wh(len(q))o<<pot(q)<<sp;rr o;}
I(J T)os&O<<(os&o,qmin<T>q){wh(len(q))o<<pot(q)<<sp;rr o;}
I(size_t n)os&O<<(os&o,cs bitset<n>&b){fo(i,n)o<<b[i];rr o;}
I(J T,J U)os&O<<(os&o,cs cp<T,U>&c){rr o<<c.a<<sp<<c.b;}
I(J T,J U)os&O<<(os&o,cs map<T,U>&m){fe(m,e)o<<cp(e)<<nl;rr o;}
I(J T,J U,J V)os&O<<(os&o,cs tr<T,U,V>&t){rr o<<t.a<<sp<<t.b<<sp<<t.c;}
I(J...A)os&O<<(os&o,cs tuple<A...>&t){
  apply([&](cs au&...a){ll i=0;(((o<<a<<str(++i!=sizeof...(a),sp))),...);},t);rr o;}
I(J V)os&O<<(os&o,cs std::vector<V>&v){fe(v,e)o<<e<<str(&e!=&rb(v),isv<V>?nl:sp);rr o;}
I(J...A)vo pp(cs A&...a){ll i=0;((cout<<a<<str(++i!=sizeof...(a),sp)),...);cout<<nl;}
I(J T,J U)is&O>>(is&i,cp<T,U>&c){rr i>>c.a>>c.b;}
I(J T,J U,J V)is&O>>(is&i,tr<T,U,V>&t){rr i>>t.a>>t.b>>t.c;}
I(J V)is&O>>(is&i,std::vector<V>&v){fe(v,e)i>>e;rr i;}
I(J...A)vo li(A&...a){(cin>>...>>a);}
I(J...A)vo vi(A&...a){fo(i,(len(a)&...))(cin>>...>>a[i]);}

cls rle(cs u1&a){cls r;fe(a,e)len(r)&&e==rb(r).a?++rb(r).b:r.eb(e,1).b;rr r;}
cls rce(u1 a){rr rle(srt(a));}

struct montgomery64{
  uu ml=montgomery64;
  uu i64=ll;
  uu u64=ull;
  uu u128=__uint128_t;

  static inline u64 m=998244353;
  static inline u64 miv;
  static inline u64 n2;

  static void set_mod(u64 m){
    assert(m<(1ULL<<63));
    assert(m&1);
    ml::m=m;
    n2=-u128(m)%m;
    miv=m;
    fo(5)miv*=2-m*miv;
    assert(m*miv==1);
  }

  static u64 mod(){
    rr m;
  }

  u64 a;
  montgomery64(cs i64&a=0):a(reduce((u128)(a%(i64)m+m)*n2)){}

  static u64 reduce(cs u128&a){
    u128 r=(a+u128(u64(a)*-miv)*m)>>64;
    rr r>=m?r-m:r;
  }

  ml&O+=(cs ml&b){if((a+=b.a)>=m)a-=m;rr*this;}
  ml&O-=(cs ml&b){if(i64(a-=b.a)<0)a+=m;rr*this;}
  ml&O*=(cs ml&b){a=reduce(u128(a)*b.a);rr*this;}
  ml&O/=(cs ml&b){*this*=b.inv();rr*this;}

  ml O+(cs ml&b)cs{rr ml(*this)+=b;}
  ml O-(cs ml&b)cs{rr ml(*this)-=b;}
  ml O*(cs ml&b)cs{rr ml(*this)*=b;}
  ml O/(cs ml&b)cs{rr ml(*this)/=b;}
  bo O==(cs ml&b)cs{rr a==b.a;}
  bo O!=(cs ml&b)cs{rr a!=b.a;}
  ml O-()cs{rr ml()-ml(*this);}

  ml pow(u128 n)cs{
    ml r(1),x(*this);
    wh(n){
      if(n&1)r*=x;
      x*=x;
      n>>=1;
    }
    rr r;
  }

  ml inv()cs{

    u64 a=this->a,b=m,u=1,v=0;
    wh(b)u-=a/b*v,swap(u,v),a-=a/b*b,swap(a,b);
    rr u;
  }

  u64 val()cs{
    rr reduce(a);
  }

  friend is&O>>(is&i,ml&b){
    ll t;i>>t;b=t;
    rr i;
  }

  friend os&O<<(os&o,cs ml&b){
    rr o<<b.val();
  }
};
uu mont=montgomery64;
uu mont1=V1<mont>;

ll inv(ll x,ll m){ll a=(x%m+m)%m,b=m,u=1,v=0;wh(b)u-=a/b*v,swap(u,v),a-=a/b*b,swap(a,b);rr(u%m+m)%m;}

I(J mont)bo miller_rabin(ll n,u1 as){
  ll t=0,d=n-1;
  wh(eve(d))d>>=1;

  if(mont::mod()!=n)mont::set_mod(n);
  mont one=1,minus_one=n-1;
  fe(as,a){
    if(a%n==0)continue;
    ll t=d;
    mont y=mont(a).pow(t);
    wh(t!=n-1&&y!=one&&y!=minus_one)y*=y,t<<=1;
    if(y!=minus_one&&eve(t))rr 0;
  }
  rr 1;
}

bo is_prime(ll n){
  if(eve(n))rr n==2;
  if(n<=1)rr 0;
  if(n<4759123141LL)rr miller_rabin<montgomery64>(n,{2,7,61});
  rr miller_rabin<montgomery64>(n,{2,325,9375,28178,450775,9780504,1795265022});
}

I(J mont)ll pollard_rho(ll n){
  if(eve(n))rr 2;
  if(is_prime(n))rr n;
  if(mont::mod()!=n)mont::set_mod(n);
  mont R,one=1;
  auto f=[&](mont x){rr x*x+R;};
  wh(1){
    mont x,y,ys,q=one;
    R=rnd(2,n),y=rnd(2,n);
    ll g=1;
    constexpr ll m=128;
    for(ll r=1;g==1;r<<=1){
      x=y;
      fo(r)y=f(y);
      for(ll k=0;g==1&&k<r;k+=m){
        ys=y;
        for(ll i=0;i<m&&i<r-k;++i)q*=x-(y=f(y));
        g=std::gcd(q.val(),n);
      }
    }
    if(g==n)do g=std::gcd((x-(ys=f(ys))).val(),n);while(g==1);
    if(g!=n)rr g;
  }
}

u1 inner_factorize(ll n){
  if(n<=1)rr{};
  ll d=pollard_rho<montgomery64>(n);
  if(d==n)rr{d};
  rr inner_factorize(d)^inner_factorize(n/d);
}

cls factorize(ll n){
  rr rce(inner_factorize(n));
}

u1 divisors(ll n){
  cls fa=factorize(n);
  ll K=len(fa);

  u1 res;
  deque<cl>q{{0,1}};
  wh(len(q)){
    auto[i,d]=pof(q);

    if(i==K){
      res.eb(d);
      continue;
    }

    fo(fa[i].b+1){
      q.eb(i+1,d);
      d*=fa[i].a;
    }
  }
  rr srt(res);
}

I(J T)struct twelvefold{
  V1<T>fa,rfa,bs;
  V2<T>m;V2<int>u;
  twelvefold(ll n):fa(n+1,1),rfa(n+1,1),bs(n+1,1){
    fo(i,1,n+1)fa[i]=fa[i-1]*i;
    rfa[n]=fa[n].inv();
    of(i,n)rfa[i]=rfa[i+1]*(i+1);
    fo(i,1,n+1)bs[i]=bs[i-1]+pwm1(i)*rfa[i];
    if(n<=5000)m.resize(n+1,V1<int>(n+1)),u.resize(n+1,V1<int>(n+1));
  }
  T O()(ll n,ll k){rr c(n,k);}
  T c(ll n,ll k){rr n<0?pwm1(k)*c(-n+k-1,k):k<0||n<k?0:fa[n]*rfa[k]*rfa[n-k];}
  T p(ll n,ll k){rr c(n,k)*fa[k];}
  T h(ll n,ll r){rr c(n-1+r,r);}
  T s(ll n,ll k){T r=0;fo(i,k+1)r+=pwm1(k-i)*c(k,i)*T(i).pow(n);rr r*rfa[k];}
  T b(ll n,ll k){T r=0;fo(i,k+1)r+=T(i).pow(n)*rfa[i]*bs[k-i];rr r;}
  T par(ll n,ll k){
    if(n==0&&k==0)rr 1;
    if(k==0)rr 0;
    if(u[n][k])rr m[n][k];
    if(n-k>=0)rr u[n][k]=1,m[n][k]=par(n,k-1)+par(n-k,k);
    rr u[n][k]=1,m[n][k]=par(n,k-1);
  }
};uu twf=twelvefold<ml>;

I(J T)struct twelvefold_table{
  V2<cp<bo,T>>mc,mp,ms;
  T c(ll n,ll k){
    if(n<k||n<0||k<0)rr 0;
    if(n==k||k==0)rr 1;
    if(mc[n][k].a)rr mc[n][k].b;
    rr(mc[n][k]={true,c(n-1,k)+c(n-1,k-1)}).b;
  }
  T p(ll n,ll k){
    T r=c(n,k);
    for(ll i=1;i<=k;i++)r*=i;
    rr r;
  }
  T h(ll n,ll k){
    rr c(n-1+k,k);
  }
  T s(ll n,ll k){
    if(n<k||n<=0||k<=0)rr 0;
    if(n==k||k==1)rr 1;
    if(ms[n][k].a)rr ms[n][k].b;
    rr(ms[n][k]={true,s(n-1,k)*k+s(n-1,k-1)}).b;
  }
  T b(ll n,ll k){
    T r=0;
    for(ll i=0;i<=k;i++)r+=s(n,i);
    rr r;
  }
  T par(ll n,ll k){
    if(n==0 and k==0)rr 1;
    if(k==0)rr 0;
    if(mp[n][k].a)rr mp[n][k].b;
    if(n-k>=0)rr(mp[n][k]={1,par(n,k-1)+par(n-k,k)}).b;
    rr(mp[n][k]={1,par(n,k-1)}).b;
  }
};

int main(){ll T=1;fo(T)solve();}
vo solve(){
  LL(N,M);
  twf tw(N);

  if(M==0){
    if(odd(N))done(0);
    ml ans=0;
    fo(k,1,N+1){
      ll i=(N+k*2)/2,j=N/2;
      ans+=tw(N,i)*tw(N,j);
    }
    ans*=4;
    ans+=tw(N,N/2).pow(2);
    pp(ans/ml(4).pow(N));
  }else{
    u1 ds=divisors(zz(M));

    cls v;
    fo(i,len(ds)){
      ll A=ds[i],B=ds[len(ds)-1-i];
      if(eve(A+B))v.eb((A+B)/2,(A-B)/2);
    }

    ml ans=0;
    fe(v,a,b){
      a=zz(a),b=zz(b);
      if(eve(N+a-b)){
        ll i=(N+a+b)/2,j=(N+a-b)/2;
        ans+=tw(N,i)*tw(N,j);
      }
    }
    pp(ans/ml(4).pow(N)*2);
  }
}
0