UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#190552#3380. xorgaojieming100126ms1208kbC++111.1kb2023-10-06 09:17:532023-10-06 12:00:51

answer

#include<bits/stdc++.h>
#define ll long long
#define il inline
#define pn putchar('\n')
#define maxint 2147483647
#define min(x,y) (x<y?x:y)
#define max(x,y) (x>y?x:y)
#define int ll
#define maxn 100005
using namespace std;
int n,ans;
int b[maxn],a[maxn],f[maxn][2];
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    #endif
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%lld",&x);
        while(x)
        {
            int y=__lg(x)+1;
            if(!b[y])b[y]=x;
            x^=b[y];
        }
    }
    n=0;
    for(int i=1;i<=30;i++)
        if(b[i])
            a[++n]=b[i];
    for(int i=0;i<30;i++)
        f[i][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0,x=a[i];j<30;x>>=1,j++)
        {
            if(x&1)
            {
                ans+=(1<<j)*f[j][0];
                f[j][0]=f[j][1]=f[j][0]+f[j][1];
            }
            else
                ans+=(1<<j)*f[j][1],f[j][0]<<=1,f[j][1]<<=1;
        }
    }
    printf("%lld",ans);
    return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1196kb

input:

1
0

output:

0

result:

ok single line: '0'

Test #2:

score: 10
Accepted
time: 12ms
memory: 1208kb

input:

100000
65921 198375 21586 38561 397862 231047 214055 475329 133011 759024 181248 331796 677542 10327...

output:

68047798272

result:

ok single line: '68047798272'

Test #3:

score: 10
Accepted
time: 14ms
memory: 1204kb

input:

100000
677027 820321 557474 70635 668211 742187 333000 807730 553720 880897 448250 504907 37563 2146...

output:

137169862656

result:

ok single line: '137169862656'

Test #4:

score: 10
Accepted
time: 14ms
memory: 1204kb

input:

100000
19965 479774 56172 281200 333015 35825 447368 476544 476331 513079 465656 312879 511426 82975...

output:

67645603840

result:

ok single line: '67645603840'

Test #5:

score: 10
Accepted
time: 10ms
memory: 1200kb

input:

100000
857727 839078 518837 441723 868634 712311 149274 174410 910286 290333 165547 1019132 415544 1...

output:

274877644800

result:

ok single line: '274877644800'

Test #6:

score: 10
Accepted
time: 14ms
memory: 1204kb

input:

100000
508190 818044 445053 771099 163392 437294 982637 725539 88101 831756 736077 289071 492073 993...

output:

274844090368

result:

ok single line: '274844090368'

Test #7:

score: 10
Accepted
time: 12ms
memory: 1200kb

input:

100000
354185019 666591573 788482649 1053188434 745934094 29050950 850330965 44770138 672555111 1038...

output:

72055111479721984

result:

ok single line: '72055111479721984'

Test #8:

score: 10
Accepted
time: 15ms
memory: 1200kb

input:

100000
168692682 146806924 180981378 441140484 479478730 378569246 306272158 234996946 206638618 513...

output:

4345200948281344

result:

ok single line: '4345200948281344'

Test #9:

score: 10
Accepted
time: 18ms
memory: 1200kb

input:

100000
592447371 856214398 558635630 352846294 538016599 589357573 892700581 318770198 913614510 684...

output:

62478648669634560

result:

ok single line: '62478648669634560'

Test #10:

score: 10
Accepted
time: 17ms
memory: 1204kb

input:

100000
864560252 956306323 403708676 410585270 67247857 394338323 943268623 779170496 587868844 2817...

output:

72036703249891328

result:

ok single line: '72036703249891328'