QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#293642 | #7601. IQ Test | ship2077 | WA | 0ms | 3772kb | C++14 | 467b | 2023-12-29 15:15:35 | 2023-12-29 15:15:36 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n;map<int,bool>f;queue<int>q;
vector<pair<int,int>>ans;
signed main(){
f[0]=f[1]=f[2]=1;
cin>>n;q.push(n);
while (!q.empty()){
int x=q.front();q.pop();
if (f[x]) continue;f[x]=1;
int tmp=ceil(sqrt(x));
ans.push_back({tmp,tmp*tmp-x});
q.push(tmp);q.push(tmp*tmp-x);
}
reverse(ans.begin(),ans.end());
for (auto [x,y]:ans)
printf("%lld %lld\n",x,y);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3732kb
input:
5
output:
2 0 2 1 3 4
result:
ok Successful, 3 queries
Test #2:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
7
output:
2 1 3 2
result:
ok Successful, 2 queries
Test #3:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
1
output:
result:
ok Successful, 0 queries
Test #4:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
29
output:
2 1 3 2 3 3 6 7
result:
ok Successful, 4 queries
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3680kb
input:
26
output:
2 0 2 1 4 6 3 3 6 10
result:
wrong answer a=4 and b=6 must be in S