Comet OJ - Contest #9 & X Round 3

A. arithmetic sequence

title

[XR-3] arithmetic sequence

Simplify the meaning of the questions:

Small X to the first two and the number of items you an arithmetic sequence, and you find that the sum of the arithmetic sequence.

Arithmetic sequence: For a \ (n-\) Number Sequence \ (A \) , if satisfied for any \ (I \ in [. 1, n-) \) , there are \ (a_ {i + 1} - a_i = d \ ) , where \ (D \) is a constant value, this number as a called arithmetic sequence.

\ (| a_1 |, | a_2 | \ 10 ^ 6 \) .

\ (3 \ n \ 10 ^ 6 \) .

analysis

Arithmetical series summation formula:
\ [S_n na_1 + = \ {n-FRAC * (. 1-n-)} {2} D \]

Note that open long long.

Time complexity: \ (O (1) \) .

code

#include<bits/stdc++.h>

typedef long long ll;

namespace IO
{
    char buf[1<<15],*fs,*ft;
    inline char getc() { return (ft==fs&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),ft==fs))?0:*fs++; }
    template<typename T>inline void read(T &x)
    {
        x=0;
        T f=1, ch=getchar();
        while (!isdigit(ch) && ch^'-') ch=getchar();
        if (ch=='-') f=-1, ch=getchar();
        while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
        x*=f;
    }

    char Out[1<<24],*fe=Out;
    inline void flush() { fwrite(Out,1,fe-Out,stdout); fe=Out; }
    template<typename T>inline void write(T x,char str)
    {
        if (!x) *fe++=48;
        if (x<0) *fe++='-', x=-x;
        T num=0, ch[20];
        while (x) ch[++num]=x%10+48, x/=10;
        while (num) *fe++=ch[num--];
        *fe++=str;
    }
}

using IO::read;
using IO::write;

int main()
{
    ll a1,a2,n;read(a1);read(a2);read(n);
    ll d=a2-a1;
    write(n*a1+(n*(n-1)/2)*d,'\n');
    IO::flush();
    return 0;
}

B. grapevine

title

XR-3 [gossip]

Simplify the meaning of the questions:

Small X want to explore how fast the speed of the spread of rumors, so he made a social experiment.

There \ (n-\) individual, wherein the first \ (I \) has a number of personal clothing \ (I +. 1 \) . X discovered a small law: when the number on a clothes \ (i \) who one day know a message, he will tell a few clothes for the next day put the information \ (j \) people, where \ (\ GCD (I, J) = 1 \) (i.e. \ (i, j \) is the greatest common divisor of \ (1 \) ). In the first \ (0 \) days, put a small X on the grapevine told \ (k \) individuals, small X would like to know when the first few days everyone will know this gossip.

It can be shown that there must everyone knows this gossip that day.

analysis

Pre-skills: Bertrand - cut Theorem Chebyshev .

The beginning is a rip off, clearly belongs to this problem if you write about this theorem, and if not understand, you have to look for a long Baidu Encyclopedia, which also how to write? (All know)

Choose to give up the game, after study end.

Read xht solution to a problem, the day turned out to be mean (Baidu Encyclopedia real harm, escape):

If \ (k + 1 \) is a prime number and \ (2 (K + 1)> n-+ 1 \) , the answer is \ (1 \) , because it necessarily \ (2 \ sim n + 1 \) of number (in addition to their own) are relatively prime.

Otherwise, the answer is \ (2 \) , because, according to Bertrand - Chebyshev Theorem, \ (K +. 1 \) necessarily \ (2 \ sim n + 1 \) the largest prime number coprime, the first day of this man has written the largest prime number will get this gossip on clothes, then everyone will know in the next day.

Time complexity: \ (O (\ sqrt n-) \) (for the determination of the number of prime time complexity).

code

#include<bits/stdc++.h>

typedef long long ll;

namespace IO
{
    char buf[1<<15],*fs,*ft;
    inline char getc() { return (ft==fs&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),ft==fs))?0:*fs++; }
    template<typename T>inline void read(T &x)
    {
        x=0;
        T f=1, ch=getchar();
        while (!isdigit(ch) && ch^'-') ch=getchar();
        if (ch=='-') f=-1, ch=getchar();
        while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
        x*=f;
    }
}

using IO::read;

inline bool check(ll k)
{
    for (int i=2; i<=sqrt(k); ++i)
        if (k%i==0) return 0;
    return 1;
}

int main()
{
    ll n,k;
    read(n);read(k);
    if (check(k+1) && (k+1)*2>n+1) puts("1");
    else puts("2");
    return 0;
}

C. The core city

title

[XR-3] core city

Simplify the meaning of the questions:

State-owned X \ (n \) cities, \ (the n-- 1 \) strip length \ (1 \) on the road, each road connecting the two cities, and any two cities can reach each other by a number of roads, obviously, cities and roads form a tree.

The king decided to country X \ (k \) cities handpicked for the country X's core cities, which \ (k \) cities need the following two conditions are met:

  1. They \ (k \) cities may, in the case of other cities without pairwise reach each other by road.
  2. The definition of a non-core city and it \ (k \) from the seat for the core of the city, and the city \ (k \) the minimum distance of the seat core of the city. Then all non-core cities, and from the largest urban core of the city, the minimum distance from the heart of the city. You need to find the minimum.

analysis

Nuclear like tree network, right, but not the same, but still able to water a lot of points.

Talk about positive solutions to it:

  • \ (k = 1 \) , it is clear that the core of the city center for the whole tree (the midpoint of the diameter).
  • \ (K \ =. 1 Not \) , as the center of the first root of the tree, then the points are sequentially added greedy core cities set until the number of core city \ (K = \) .
    • The key, how greedy?
    • Define \ (F (x) \) when the root of the tree center point \ (x \) the maximum distance from their own sub-tree leaves.
    • So Figure greedy strategy is: every time the core of the city currently determined connected non-core city selection \ (f \) largest city added to the core cities. (I use the Queue maintenance)
  • Solving, time complexity: \ (O (the n-\ the n-log) \) .

code

#include<bits/stdc++.h>

const int maxn=1e5+10;

namespace IO
{
    char buf[1<<15],*fs,*ft;
    inline char getc() { return (ft==fs&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),ft==fs))?0:*fs++; }
    template<typename T>inline void read(T &x)
    {
        x=0;
        T f=1, ch=getchar();
        while (!isdigit(ch) && ch^'-') ch=getchar();
        if (ch=='-') f=-1, ch=getchar();
        while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
        x*=f;
    }

    char Out[1<<24],*fe=Out;
    inline void flush() { fwrite(Out,1,fe-Out,stdout); fe=Out; }
    template<typename T>inline void write(T x,char str)
    {
        if (!x) *fe++=48;
        if (x<0) *fe++='-', x=-x;
        T num=0, ch[20];
        while (x) ch[++num]=x%10+48, x/=10;
        while (num) *fe++=ch[num--];
        *fe++=str;
    }
}

using IO::read;
using IO::write;

int ver[maxn<<1],Next[maxn<<1],head[maxn],len,In[maxn];
inline void add(int x,int y)
{
    ver[++len]=y,Next[len]=head[x],head[x]=len,++In[y];
}

int dep[maxn],cnt[maxn];
int main()
{
    int n,k;read(n);read(k);
    for (int i=1,x,y; i<n; ++i) read(x),read(y),add(x,y),add(y,x);
    std::queue<int>q;
    for (int i=1; i<=n; ++i)
        if (In[i]==1) q.push(i),dep[i]=1;
    while (!q.empty())
    {
        int x=q.front();
        q.pop();
        for (int i=head[x]; i; i=Next[i])
        {
            int y=ver[i];
            if (In[y]==1) continue;
            dep[y]=std::max(dep[y],dep[x]+1);
            if (--In[y]==1) q.push(y);
        }
    }
    for (int i=1; i<=n; ++i) ++cnt[dep[i]];
    int sum=0;
    for (int i=1; i<=n; ++i)
    {
        sum+=cnt[i];
        if (n-sum<=k) { write(i,'\n'); break; }
    }
    IO::flush();
    return 0;
}

D. System Design

title

[XR-3 System Design

Simplify the meaning of the questions:

You need to design a small X system.

The system first needs to enter a \ (n-\) rooted tree and a length of points \ (m \) sequence \ (A \) , then need to achieve \ (Q \) operations.

Operating in two ways:

  1. 1 x l rIndicates the starting point is set as a rooted tree of nodes \ (X \) , followed in order by traversing \ (L \ R & lt SIM \) . When traversing to \ (i \) when, from the current node to its number of \ (a_i \) small son. If the number of son nodes is less than a current time \ (a_i \) , or has traversed \ (L \ R & lt SIM \) , then stopped at this point, and outputs the number of points, while stopping traversal.

  2. 2 t kIt shows a sequence of \ (T \) number \ (a_t \) modify \ (K \) .

analysis

Pre-skills:

  • String hash;
  • An array of trees / tree line half (Famous last words written segment tree).

This question is the topic and people strongly recommended uncle xht of \ (Blog \) . (I do not want to draw).

code

#include<bits/stdc++.h>

typedef long long ll;
const int maxn=5e5+10;
typedef int iarr[maxn];

namespace IO
{
    char buf[1<<15],*fs,*ft;
    inline char getc() { return (ft==fs&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),ft==fs))?0:*fs++; }
    template<typename T>inline void read(T &x)
    {
        x=0;
        T f=1, ch=getchar();
        while (!isdigit(ch) && ch^'-') ch=getchar();
        if (ch=='-') f=-1, ch=getchar();
        while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
        x*=f;
    }

    char Out[1<<24],*fe=Out;
    inline void flush() { fwrite(Out,1,fe-Out,stdout); fe=Out; }
    template<typename T>inline void write(T x,char str)
    {
        if (!x) *fe++=48;
        if (x<0) *fe++='-', x=-x;
        T num=0, ch[20];
        while (x) ch[++num]=x%10+48, x/=10;
        while (num) *fe++=ch[num--];
        *fe++=str;
    }
}

using IO::read;
using IO::write;

template<typename T>inline bool chkMin(T &a,const T &b) { return a>b ? (a=b, true) : false; }
template<typename T>inline bool chkMax(T &a,const T &b) { return a<b ? (a=b, true) : false; }
template<typename T>inline T min(T a,T b) { return a<b ? a : b; }
template<typename T>inline T max(T a,T b) { return a>b ? a : b; }

ll P[maxn];
int n,m,q,rt,id;
struct Hash_Table
{
    ll c[maxn];
    inline int lowbit(int x) { return x & -x; }
    inline void add(int x,ll y) { y*=P[x]; while (x<=n) c[x]+=y, x+=lowbit(x); }
    inline ll ask(int x) { ll ans=0; while (x) ans+=c[x], x-=lowbit(x); return ans; }
    inline ll hsh(int l,int r) { return (ask(r)-ask(l-1))*P[maxn-1-l]; }
}T1, T2;

std::vector<int>v[maxn];
iarr siz,dfn,top,pos,ed,a,fa;
inline void dfs1(int x)
{
    siz[x]=1;
    sort(v[x].begin(),v[x].end());
    for (int i=0; i<(int)v[x].size(); ++i)
    {
        int y=v[x][i];
        dfs1(y);
        siz[x]+=siz[y];
    }
}

inline void dfs2(int x,int topf)
{
    dfn[x]=++id;
    ed[x]=x;
    top[x]=topf;
    pos[id]=x;
    if (!v[x].size())
    {
        T1.add(dfn[x],-23333);
        return ;
    }
    int t=0;
    for (int i=1; i<(int)v[x].size(); ++i)
        if (siz[v[x][i]]==siz[v[x][t]]) t=i;
    dfs2(v[x][t],topf);
    ed[x]=ed[v[x][t]];
    T1.add(dfn[x],t+1);
    for (int i=0; i<(int)v[x].size(); ++i)
        if (i^t) dfs2(v[x][i],v[x][i]);
}

inline int LCP(int L,int R,int l,int r)
{
    int lp=1, rp=min(R-L+1,r-l+1), ans=0;
    while (lp<=rp)
    {
        int mid=(lp+rp)>>1;
        if (T1.hsh(L,L+mid-1)==T2.hsh(l,l+mid-1)) ans=mid, lp=mid+1;
        else rp=mid-1;
    }
    return ans;
}

inline int solve(int x,int l,int r)
{
    int L=dfn[x], R=dfn[ed[x]];
    while (1)
    {
        int len=LCP(L,R,l,r);
        L+=len, l+=len;
        int x=pos[L];
        if (l>r || v[x].size()<a[l]) return x;
        x=v[x][a[l]-1];
        L=dfn[x], R=dfn[ed[x]];
        ++l;
        if (l>r) return x;
    }
}

int main()
{
    P[0]=1;
    for (int i=1; i<maxn; ++i) P[i]=P[i-1]*4238197ll;
    read(n);read(m);read(q);
    for (int i=1; i<=n; ++i)
    {
        read(fa[i]);
        if (!fa[i]) rt=i;
        v[fa[i]].push_back(i);
    }
    dfs1(rt);
    dfs2(rt,rt);
    for (int i=1; i<=m; ++i) read(a[i]), T2.add(i,a[i]);
    while (q--)
    {
        int opt;read(opt);
        if (opt==1)
        {
            int x,l,r;
            read(x);read(l);read(r);
            write(solve(x,l,r),'\n');
        }
        else
        {
            int t,k;read(t);read(k);
            T2.add(t,k-a[t]);
            a[t]=k;
        }
    }
    IO::flush();
    return 0;
}

E. Namid[A]me

title

【XR-3】Namid[A]me

Simplify the meaning of the questions:

X gives you a little \ (n \) points of the tree, a little dot right.

You need to find the following equation die \ (786,433 \) values:

\ (\ Sum_ {1 \ leq u \ leq v \ leq n} f (u, v) ^ {f (u, v)} \)

Wherein \ (f (u, v) \) represents \ (U \) to \ (V \) in all points of the right point on the shortest path after the bit values together.

Tip: In order to facilitate your calculations, where we believe that \ (0 ^ 0 = 0 \) . In addition, \ (786,433 \) is a prime number, but also a less common NTT modulus, its original roots \ (10 \) , if you do not know what NTT or do not know what is the original root, you can ignore this prompted.

analysis

How to quickly calculate \ (the X-the X-^ \ MOD P \) ? Quick to get power.

Next step is to consider how to calculate the tree a chain.

All this time the chain is the equivalent of a range, consider enumerate the right point \ (r \) , then for \ ([l, r] \ ) of all numbers within the set \ (X_L \) , note that if \ ( X_L ≠ X_ {L +. 1} \) , since \ (X_L = X_ {L +. 1} \ OperatorName {\ texttt {and}} A_L \) , then there must be at least \ (x_ {l + 1} \) one bit from \ (1 \) becomes \ (0 \) .

Therefore, \ (X_L \) to \ (x_1 \) , bound to at most \ (w + 1 \) optional values. We consider only maintenance is taken to value were taken to how many times you can.

Subtree processing section:

  1. For a \ (D \) th sub-tree leaves, when in the maintenance sub-tree of each node to the root of the subtree on the path of and a total of not more than \ (d (w + 1) \) optional values this is because each leaf to the root of one strand of the value of each no more than \ (w + 1 \) , so we only have to maintain in the process of DFS in each sub-tree inside appear to all be able to take the values of the number of times you can. The complexity of this part is \ (O (NDW) \) .
  2. Need to calculate the path of the two end points in a path different sub-tree of the answer, this part of the violence we enumerate, noticed two leaves only in their position LCA contribution to the complexity of the merger \ ((w + 1) ^ 2 \ ) , so the total cost of computing this part of the answer is \ (O ((DW) ^ 2) \) . But there is also an upper limit \ (O (the n-^ 2) \) , because only so many paths.

Since \ (O (min (n-, DW) ^ 2) \ leqslant O (NDW) \) , so the total time complexity is \ (O (NDW) \) .

Solution to a problem of solving the problem are basically referring XHT , people write is really detailed, still thinking clearly.

code

#include<bits/stdc++.h>

const int maxn=2e5+10,mod=786433;

namespace IO
{
    char buf[1<<15],*fs,*ft;
    inline char getc() { return (ft==fs&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),ft==fs))?0:*fs++; }
    template<typename T>inline void read(T &x)
    {
        x=0;
        T f=1, ch=getchar();
        while (!isdigit(ch) && ch^'-') ch=getchar();
        if (ch=='-') f=-1, ch=getchar();
        while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
        x*=f;
    }

    char Out[1<<24],*fe=Out;
    inline void flush() { fwrite(Out,1,fe-Out,stdout); fe=Out; }
    template<typename T>inline void write(T x,char str)
    {
        if (!x) *fe++=48;
        if (x<0) *fe++='-', x=-x;
        T num=0, ch[20];
        while (x) ch[++num]=x%10+48, x/=10;
        while (num) *fe++=ch[num--];
        *fe++=str;
    }
}

using IO::read;
using IO::write;

template<typename T>inline T min(T a,T b) { return a<b ? a : b; }
template<typename T>inline T max(T a,T b) { return a>b ? a : b; }

inline int Quick_power(int a)
{
    if (!a) return 0;
    int ans=1, b=a;
    while (b)
    {
        if (b&1) ans=1ll*ans*a%mod;
        a=1ll*a*a%mod;
        b>>=1;
    }
    return ans;
}

int ans;
struct Orz
{
    int a[maxn],b[maxn],c[maxn];
    inline void Clear()
    {
        *a=0;
    }

    inline void insert(int x)
    {
        a[++*a]=x;
    }

    inline void solve(int val)
    {
        std::sort(a+1,a+*a+1);
        int top=0, last=1;
        for (int i=2; i<=(int)(*a)+1; ++i)
            if (i==(*a)+1 || a[i]^a[i-1]) b[++top]=a[i-1], c[top]=i-last, last=i;
        int sum=0;
        for (int i=1; i<=top; ++i)
            for (int j=i; j<=top; ++j)
            {
                int times=( i==j ? 1ll*c[i]*(c[i]+1)/2%mod : 1ll*c[i]*c[j]%mod );
                sum=(sum+1ll*times*Quick_power(b[i]&b[j]))%mod;
            }
        ans=(ans+1ll*val*sum)%mod;
    }
}T1, T2;

int ver[maxn<<1],Next[maxn<<1],head[maxn],len;
inline void add(int x,int y)
{
    ver[++len]=y,Next[len]=head[x],head[x]=len;
}

int siz[maxn],pos,maxv;
bool vis[maxn];
inline void dfs(int x,int fa,int n)//这里的 n 必须做传参一起传过去,不然蜜汁 TLE
{
    siz[x]=1;
    int maxpart=0;
    for (int i=head[x];i;i=Next[i])
    {
        int y=ver[i];
        if (vis[y] || y==fa) continue;
        dfs(y,x,n);
        siz[x]+=siz[y];
        maxpart=max(maxpart,siz[y]);
    }
    maxpart=max(maxpart,n-siz[x]);
    if (maxpart<maxv) maxv=maxpart, pos=x;
}

int a[maxn];
inline void get(int x,int fa,int val)
{
    val&=a[x];
    T1.insert(val);
    T2.insert(val);
    for (int i=head[x]; i; i=Next[i])
    {
        int y=ver[i];
        if (y==fa || vis[y]) continue;
        get(y,x,val);
    }
}

inline void divide(int x,int n)
{
    maxv=1<<30;
    dfs(x,0,n);
    vis[x=pos]=1;
    T1.Clear();
    T1.insert(a[x]);
    for (int i=head[x]; i; i=Next[i])
    {
        int y=ver[i];
        if (vis[y]) continue;
        T2.Clear();
        get(y,x,a[x]);
        T2.solve(mod-1);
    }
    T1.solve(1);
    for (int i=head[x]; i; i=Next[i])
    {
        int y=ver[i];
        if (!vis[y]) divide(y,siz[y]>siz[x] ? n-siz[x] : siz[y]);
    }
}

int main()
{
    int n;read(n);
    for (int i=1; i<=n; ++i) read(a[i]);
    for (int i=1,x,y; i<n; ++i) read(x),read(y),add(x,y),add(y,x);
    divide(1,n);
    write(ans,'\n');
    IO::flush();
    return 0;
}

F. Unknown Mother-Goose

title

【XR-3】Unknown Mother-Goose

Simplify the meaning of the questions:

X got a small positive integer \ (n \) and a set of positive integers \ (S \) , he wanted to know how many there are positive integers (x \) \ satisfies all of the following conditions:

  • \ (3 \ X \ n \)
  • Presence \ (a \ in S, x \ equiv 0 \ mod a \)
  • Presence \ (b \ in S, x -1 \ equiv 0 \ mod b \)
  • Presence \ (c \ in S, x -2 \ equiv 0 \ mod c \)

Please help small X seeking out.

analysis

Game, see this title, thought to be the solution congruence equation, too le, I'm gone.

After seeing solution to a problem, this problem can also use \ (bitset \) Write violence marked count? This is too god it.

In \ (the bitset \) in the yes \ (S \) subscript a multiple of each element in all assigned to \ (1 \) , then, if \ (a_x, a_ {x- 1}, a_ {x + 1} \) is \ (1 \) , \ (the X-\) is legitimate.

The question then becomes the number \ (bitset \) , there are several groups of three consecutive \ (1 \) .

May each be \ (64 \) bit-one, inside the block count has several sets of three consecutive \ (1 \) , then there is calculated between the block and the block groups of three consecutive \ (1 \) , the enumeration click.

Time complexity: \ (O (\ {n-FRAC. 8} {}) \) .

Big brother can also proposed \ (S \) in an element is greater than \ (64 \) to points where treatment can run faster (see further explanations particular big brother).

The total time complexity \ (O (\ {n-FRAC | S |} + {64} \ {n-FRAC. 8} {}) \) (high looks good, but does not address continuous process frequently call the system stack, it can quickly pass).

Good wonderful. Good wonderful. Good wonderful.

code

#include<bits/stdc++.h>

typedef unsigned long long ull;
const int maxn=1e9+1,maxm=1e5+10,grhsmt=(1<<16)-1;

namespace IO
{
    char buf[1<<15],*fs,*ft;
    inline char getc() { return (ft==fs&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),ft==fs))?0:*fs++; }
    template<typename T>inline void read(T &x)
    {
        x=0;
        T f=1, ch=getchar();
        while (!isdigit(ch) && ch^'-') ch=getchar();
        if (ch=='-') f=-1, ch=getchar();
        while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
        x*=f;
    }

    char Out[1<<24],*fe=Out;
    inline void flush() { fwrite(Out,1,fe-Out,stdout); fe=Out; }
    template<typename T>inline void write(T x,char str)
    {
        if (!x) *fe++=48;
        if (x<0) *fe++='-', x=-x;
        T num=0, ch[20];
        while (x) ch[++num]=x%10+48, x/=10;
        while (num) *fe++=ch[num--];
        *fe++=str;
    }
}

using IO::read;
using IO::write;

int cnt[maxm],ans;
ull t[maxn/64+555],s[1005];
int main()
{
    int n,S;read(n);read(S);
    for (int i=1,x; i<=S; ++i)
    {
        read(x);
        if (x>100)
            for (int j=0; j<=n; j+=x) t[j>>6]|=1ull<<(j&63);
        else
        {
            for (int j=0; j<x; ++j) s[j]=0;
            for (int j=0; j<=63; ++j)
            {
                int p=j*x;
                s[p>>6]|=1ull<<(p&63);
            }
            int j=0;
            for ( ; j+x*64<=n; j+=x*64)
                for (int k=0, q=j/64; k<x; ++k) t[q+k]|=s[k];
            for ( ; j<=n; j+=x) t[j>>6]|=1ull<<(j&63);
        }
    }
    if (t[0]&1) --t[0];
    for (int i=0; i<=grhsmt; ++i) cnt[i]=cnt[i>>1]+(i&1);
    for (int i=0, l=0; l<=n; l+=64, ++i)
    {
        ull tmp=t[i]&(t[i]>>1)&(t[i]<<1);
        ans+=cnt[tmp & grhsmt], tmp>>=16;
        ans+=cnt[tmp & grhsmt], tmp>>=16;
        ans+=cnt[tmp & grhsmt], tmp>>=16;
        ans+=cnt[tmp & grhsmt];
        if ((t[i]>>63) && (t[i+1]<<63))
        {
            if (t[i]&(1ull<<62)) ++ans;
            if (t[i+1]&2) ++ans;
        }
    }
    write(ans,'\n');
    IO::flush();
    return 0;
}

Guess you like

Origin www.cnblogs.com/G-hsm/p/11426252.html