QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#225978 | #7585. TDL | ucup-team004# | AC ✓ | 48ms | 3668kb | C++20 | 692b | 2023-10-25 13:52:22 | 2023-10-25 13:52:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=500;
typedef long long ll;
bool chk(ll n,int m,int k){
if(!n)return 0;
int cnt=0;
for(int i=1;i<=k;++i){
if(gcd(n,i)==1)
++cnt;
if(cnt==m)
return i==k;
}
return 0;
}
void solve(ll k,int m){
ll ans=LLONG_MAX;
for(int i=1;i<N;++i)
if(chk(k^i,m,i))
ans=min(ans,k^i);
if(ans==LLONG_MAX)
ans=-1;
cout<<ans<<'\n';
return;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);
int T;
for(cin>>T;T --> 0;){
ll k;int m;
cin>>k>>m;
solve(k,m);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
input:
2 3 5 6 100
output:
5 -1
result:
ok 2 number(s): "5 -1"
Test #2:
score: 0
Accepted
time: 48ms
memory: 3668kb
input:
10 525775438567843653 99 682312746347646949 100 928247462368723598 89 389467864734767741 77 734712353456789580 91 928574865348354786 95 56042586089579521 93 614889782588491751 60 614889782588490923 90 614889782588491001 100
output:
-1 682312746347646754 928247462368723467 389467864734767645 734712353456789527 928574865348354669 56042586089579704 614889782588491410 614889782588490776 614889782588490814
result:
ok 10 numbers