QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#219780 | #7585. TDL | PhantomThreshold# | AC ✓ | 118ms | 3564kb | C++20 | 591b | 2023-10-19 18:14:47 | 2023-10-19 18:14:48 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=9e18;
const ll lim=1000;
ll solve(ll m,ll k){
ll ans=INF;
for (ll t=1;t<=lim;t++){
ll n=k^t;
if (__gcd(n,t)!=1) continue;
ll cnt=0;
for (ll i=1;i<=t;i++) if (__gcd(n,i)==1) cnt++;
if (cnt==m) ans=min(ans,n);
}
if (ans==INF) return -1;
else return ans;
}
int main(){
ios_base::sync_with_stdio(false);
int Tcase=10;
cin >> Tcase;
for (;Tcase--;){
long long m=100;
long long k=1e18;
cin >> k >> m;
cout << (long long)solve(m,k) << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 17ms
memory: 3564kb
input:
2 3 5 6 100
output:
5 -1
result:
ok 2 number(s): "5 -1"
Test #2:
score: 0
Accepted
time: 118ms
memory: 3444kb
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