QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#207916 | #6641. XOR Dice | UFRJ# | WA | 31ms | 8280kb | C++14 | 922b | 2023-10-08 22:59:01 | 2023-10-08 22:59:02 |
Judging History
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<<"\n";
}
}
int main(){
cin.tie(0)->sync_with_stdio(false);
int n, d;
cin>>n>>d;
solve(d, n);
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 31ms
memory: 8280kb
input:
3 2
output:
512 1024 262144 65536 4096 512 1024 262144 65536 4096 512 1024 262144 65536 4096
result:
wrong answer Invalid output