QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#226962#6804. Gaokaojzh#AC ✓1ms4256kbC++20722b2023-10-26 19:10:052023-10-26 19:10:05

Judging History

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

  • [2023-10-26 19:10:05]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:4256kb
  • [2023-10-26 19:10:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int a[1000][1000];
ll ans[1000];


ll fun(ll x) {
    if (x <= 100) return ans[x];
    ll tmp = 1;
    for (; tmp<x; tmp*=2);
    tmp /= 2;

    return fun(x-tmp)*2;
}



void solve()
{
    ll n;
    scanf("%lld", &n);
    printf("%lld\n", fun(n));
}




int main()
{
    a[1][1] = ans[1] = 1;
    for (int i=2; i<=100; i++) {
        a[i][1] = a[i][i] = 1;
        for (int j=2; j<i; j++) a[i][j] = a[i-1][j-1]^a[i-1][j];
        for (int j=1; j<=i; j++) a[i][0] += (a[i][j]==1);
        ans[i] = a[i][0];
    }
    int ttt;
    scanf("%d", &ttt);
    while (ttt--) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 4184kb

input:

3
3
4
5

output:

2
4
2

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 4256kb

input:

500
111058001134961664
26968520849635848
509420945049900
18345473009634060
10009387904720400
297995201763124320
1199969742422880
27593767872281520
12147313869018720
228953305968050664
60157185945667200
4287882807470592
357843344256000
8916055719925032
2816902778447205
377208379246423608
928877182961...

output:

4294967296
1073741824
33554432
67108864
4294967296
134217728
134217728
67108864
1073741824
268435456
2147483648
17179869184
2147483648
68719476736
33554432
1073741824
134217728
536870912
68719476736
16777216
4294967296
17179869184
17179869184
8388608
4294967296
536870912
2147483648
1073741824
167772...

result:

ok 500 lines