QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#207918#6641. XOR DiceUFRJ#AC ✓41ms8832kbC++14942b2023-10-08 23:01:052023-10-08 23:01:05

Judging History

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

  • [2023-10-08 23:01:05]
  • 评测
  • 测评结果:AC
  • 用时:41ms
  • 内存:8832kb
  • [2023-10-08 23:01:05]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

const int LIM = 1000000;

void solve(int d, int N){
    vector<int> v; v.reserve(LIM + 1);
    for(int cur = 1; cur*d <= LIM; cur ++)
        v.push_back(cur * d);
    auto v2 = v;
    sort(v2.begin(), v2.end());
    sort(v.begin(), v.end(), [](int a, int b){
        return __builtin_popcount(a) < __builtin_popcount(b); 
    });
    vector<int> ans;
    int accum = 0;
    for(int x : v){
        if((x | accum) == (x ^ accum)){
            ans.push_back(x);
            accum += x;
        }
        if(ans.size() == 5) break;
    }
    if(ans.size() == 4){
        ans.push_back(ans[0] + ans[1]);
    }
    assert(ans.size() == 5);
    while(N--){
        for(int x : ans) cout<<x<<" ";
        cout<<"0";
        cout<<"\n";
    }
}


int main(){
    cin.tie(0)->sync_with_stdio(false);
    int n, d;
    cin>>n>>d;
    solve(d, n);
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 41ms
memory: 7264kb

input:

3 2

output:

512 1024 262144 65536 4096 0
512 1024 262144 65536 4096 0
512 1024 262144 65536 4096 0

result:

ok Correct answer

Test #2:

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

input:

100 60

output:

40980 135240 606240 263040 176220 0
40980 135240 606240 263040 176220 0
40980 135240 606240 263040 176220 0
40980 135240 606240 263040 176220 0
40980 135240 606240 263040 176220 0
40980 135240 606240 263040 176220 0
40980 135240 606240 263040 176220 0
40980 135240 606240 263040 176220 0
40980 135240...

result:

ok Correct answer

Test #3:

score: 0
Accepted
time: 41ms
memory: 8296kb

input:

99 2

output:

512 1024 262144 65536 4096 0
512 1024 262144 65536 4096 0
512 1024 262144 65536 4096 0
512 1024 262144 65536 4096 0
512 1024 262144 65536 4096 0
512 1024 262144 65536 4096 0
512 1024 262144 65536 4096 0
512 1024 262144 65536 4096 0
512 1024 262144 65536 4096 0
512 1024 262144 65536 4096 0
512 1024 2...

result:

ok Correct answer

Test #4:

score: 0
Accepted
time: 2ms
memory: 3632kb

input:

99 59

output:

262432 132160 2065 16520 569350 0
262432 132160 2065 16520 569350 0
262432 132160 2065 16520 569350 0
262432 132160 2065 16520 569350 0
262432 132160 2065 16520 569350 0
262432 132160 2065 16520 569350 0
262432 132160 2065 16520 569350 0
262432 132160 2065 16520 569350 0
262432 132160 2065 16520 569...

result:

ok Correct answer

Test #5:

score: 0
Accepted
time: 5ms
memory: 3620kb

input:

93 17

output:

16388 8194 544 557056 65552 0
16388 8194 544 557056 65552 0
16388 8194 544 557056 65552 0
16388 8194 544 557056 65552 0
16388 8194 544 557056 65552 0
16388 8194 544 557056 65552 0
16388 8194 544 557056 65552 0
16388 8194 544 557056 65552 0
16388 8194 544 557056 65552 0
16388 8194 544 557056 65552 0
...

result:

ok Correct answer

Test #6:

score: 0
Accepted
time: 2ms
memory: 3612kb

input:

100 49

output:

802816 200704 49 2058 40964 0
802816 200704 49 2058 40964 0
802816 200704 49 2058 40964 0
802816 200704 49 2058 40964 0
802816 200704 49 2058 40964 0
802816 200704 49 2058 40964 0
802816 200704 49 2058 40964 0
802816 200704 49 2058 40964 0
802816 200704 49 2058 40964 0
802816 200704 49 2058 40964 0
...

result:

ok Correct answer

Test #7:

score: 0
Accepted
time: 16ms
memory: 6760kb

input:

100 5

output:

524800 2080 163840 5 4160 0
524800 2080 163840 5 4160 0
524800 2080 163840 5 4160 0
524800 2080 163840 5 4160 0
524800 2080 163840 5 4160 0
524800 2080 163840 5 4160 0
524800 2080 163840 5 4160 0
524800 2080 163840 5 4160 0
524800 2080 163840 5 4160 0
524800 2080 163840 5 4160 0
524800 2080 163840 5...

result:

ok Correct answer

Test #8:

score: 0
Accepted
time: 2ms
memory: 3648kb

input:

1 57

output:

525312 2052 8208 65664 131328 0

result:

ok Correct answer

Test #9:

score: 0
Accepted
time: 4ms
memory: 3620kb

input:

1 22

output:

270336 16896 4224 1056 524304 0

result:

ok Correct answer

Test #10:

score: 0
Accepted
time: 2ms
memory: 3944kb

input:

1 60

output:

40980 135240 606240 263040 176220 0

result:

ok Correct answer

Test #11:

score: 0
Accepted
time: 37ms
memory: 8832kb

input:

1 2

output:

512 1024 262144 65536 4096 0

result:

ok Correct answer

Test #12:

score: 0
Accepted
time: 4ms
memory: 5468kb

input:

10 24

output:

264192 16512 24 524544 8256 0
264192 16512 24 524544 8256 0
264192 16512 24 524544 8256 0
264192 16512 24 524544 8256 0
264192 16512 24 524544 8256 0
264192 16512 24 524544 8256 0
264192 16512 24 524544 8256 0
264192 16512 24 524544 8256 0
264192 16512 24 524544 8256 0
264192 16512 24 524544 8256 0

result:

ok Correct answer