QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#544732#1176. Binomialship2077AC ✓346ms12044kbC++14647b2024-09-02 19:49:142024-09-02 19:49:15

Judging History

你现在查看的是最新测评结果

  • [2024-09-02 19:49:15]
  • 评测
  • 测评结果:AC
  • 用时:346ms
  • 内存:12044kb
  • [2024-09-02 19:49:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int M=(1<<20)+5;
int n,a[M],b[M];
int read(){
    int x=0;char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-48,ch=getchar();
    return x;
}
void solve(){ n=read();
    for (int i=0;i<1<<20;i++) a[i]=b[i]=0;
    for (int i=1;i<=n;i++){
        int x=read();a[x]++;b[x]++;
    } long long ans=0;
    for (int i=0;i<20;i++)
        for (int j=0;j<1<<20;j++)
            if (j>>i&1) b[j]+=b[j^1<<i];
    for (int i=0;i<1<<20;i++) ans+=1ll*a[i]*b[i];
    printf("%lld\n",ans);
}
int main(){int T=read();while (T--) solve();return 0;}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 33ms
memory: 11928kb

input:

2
3
1 5 6
3
1 1 1

output:

4
9

result:

ok 2 number(s): "4 9"

Test #2:

score: 0
Accepted
time: 147ms
memory: 12044kb

input:

10
1
1
3321
108907 496886 513637 107549 602502 235745 583320 401703 649106 841450 806050 127630 250786 780434 780387 256680 723365 604626 255396 251497 992405 594166 951810 524404 585892 85571 821715 581042 711296 187617 367585 862536 856196 312147 121285 967957 495031 855565 619680 318939 618420 91...

output:

1
38911
1158
22249
2006
3213
15043
426
88
1191

result:

ok 10 numbers

Test #3:

score: 0
Accepted
time: 346ms
memory: 11980kb

input:

10
1000000
319659 282355 805517 492423 78447 187157 262446 533612 55339 671293 251238 188866 598658 986 776564 371192 215026 344057 213583 577027 674883 552835 500207 727954 489932 483338 232733 115534 570113 151973 327011 625780 642233 103699 19128 835797 38112 153973 826458 967214 835438 460333 55...

output:

2878293352
2895860805
2882764772
2873109297
899786118
2881907624
2877368557
2878876021
2886310256
1000000000000

result:

ok 10 numbers

Test #4:

score: 0
Accepted
time: 327ms
memory: 11868kb

input:

10
1000000
718932 525438 143858 344614 550176 446529 196655 638381 759927 201969 993978 241046 764752 912950 618918 311293 125072 501708 425676 818137 48751 850412 17011 377597 877339 595417 993334 770612 588927 392617 877160 132425 313060 791691 452471 128719 115560 788866 333356 871641 805214 9461...

output:

2878293352
1000000000000
1000000000000
1000000000000
1000000000000
415869837
1000000000000
1000000000000
1000000000000
1000000000000

result:

ok 10 numbers