QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#501137 | #6138. Function and Function | WTR2007# | AC ✓ | 11ms | 3820kb | C++20 | 1.2kb | 2024-08-02 14:43:07 | 2024-08-02 14:43:07 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define MULT_TEST 1
using namespace std;
typedef long double ldb;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
int val[10] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1};
inline int read() {
int w = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
w = (w << 1) + (w << 3) + ch - 48;
ch = getchar();
}
return w * f;
}
inline void Solve() {
int x, k, ans = -1;
x = read(); k = read();
for (int i = 1; i <= k; i++) {
if (x == 1 || x == 0) {
ans = x ^ ((k - i + 1) & 1);
break;
}
int sum = 0;
for (int j = 0, cp = x; j <= 10 && cp; j++) {
sum += val[cp % 10];
cp /= 10;
}
x = sum;
}
if (ans == -1) printf("%lld\n", x);
else printf("%lld\n", ans);
}
signed main() {
int _ = 1;
#if MULT_TEST
_ = read();
#endif
while (_--) Solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
input:
6 123456789 1 888888888 1 888888888 2 888888888 999999999 98640 12345 1000000000 0
output:
5 18 2 0 0 1000000000
result:
ok 6 numbers
Test #2:
score: 0
Accepted
time: 11ms
memory: 3820kb
input:
100000 579268184 2 120252252 777743676 255650198 1 152055433 207664522 137430584 754115403 646417467 164848484 743551976 0 0 408695577 363072674 569574204 464290891 0 761830281 3 0 1 49176280 2 791182580 0 474930784 3 402374924 0 739903247 91553857 0 2 688106229 2 65907033 152261569 875191599 3 5319...
output:
0 0 5 0 1 1 743551976 1 1 464290891 0 1 1 791182580 1 402374924 0 0 2 0 1 1 2 1 0 0 0 3 0 0 0 1 0 0 1 0 2 0 1 1 1 0 1 0 0 0 0 0 0 1 55349255 486354015 1 1 0 1 1 0 1 1 0 1 0 9 0 1 1 0 0 1 0 1 1 1 0 0 0 0 25600152 0 0 1 22903397 705086250 771453912 1 1 0 0 1 0 1 1 1 2 1 1 1 1 1 1 6 3 3 1 0 1 0 1 86248...
result:
ok 100000 numbers