QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#226716 | #7585. TDL | 8BQube# | AC ✓ | 282ms | 3780kb | C++20 | 802b | 2023-10-26 14:24:56 | 2023-10-26 14:24:57 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define pb push_back
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(), v.end()
ll f(ll n, int m) {
for (ll x = n + 1; ; ++x) {
if (gcd(n, x) == 1) {
if (--m == 0) return x;
}
}
}
ll solve() {
ll k;
int m;
cin >> k >> m;
vector<ll> v;
for (ll d = 0; d <= 2000; ++d) {
if (k == d) continue;
v.push_back(k ^ d);
}
sort(v.begin(), v.end());
for (ll n : v) {
if (((f(n, m) - n) ^ n) == k) return n;
}
return -1;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int T;
cin >> T;
while (T--) cout << solve() << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 13ms
memory: 3644kb
input:
2 3 5 6 100
output:
5 -1
result:
ok 2 number(s): "5 -1"
Test #2:
score: 0
Accepted
time: 282ms
memory: 3780kb
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