QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#309213 | #6138. Function and Function | Alex_Wei | AC ✓ | 70ms | 3996kb | C++14 | 1.3kb | 2024-01-20 15:43:36 | 2024-01-20 15:43:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;
using ull = unsigned long long;
using LL = __int128_t;
#define ppc(x) __builtin_popcount(x)
#define clz(x) __builtin_clz(x)
bool Mbe;
constexpr int mod = 1e9 + 7;
void addt(int &x, int y) {
x += y, x >= mod && (x -= mod);
}
int add(int x, int y) {
return x += y, x >= mod && (x -= mod), x;
}
// ---------- templates above ----------
constexpr int N = 1e5 + 5;
int w[10] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1};
int f(int x) {
int ans = 0;
while(x) ans += w[x % 10], x /= 10;
return ans;
}
void solve() {
int x, k;
cin >> x >> k;
while(x && k) x = f(x), k--;
if(k) x = (k & 1 ? 1 : 0);
cout << x << endl;
}
bool Med;
signed main() {
fprintf(stderr, "%.3lf MB\n", (&Mbe - &Med) / 1048576.0);
// ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef ALEX_WEI
FILE* IN = freopen("1.in", "r", stdin);
FILE* OUT = freopen("1.out", "w", stdout);
#endif
int T = 1;
cin >> T;
while(T--) solve();
fprintf(stderr, "%.3lf ms\n", 1e3 * clock() / CLOCKS_PER_SEC);
return 0;
}
/*
g++ a.cpp -o a -std=c++14 -O2 -DALEX_WEI
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3996kb
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: 70ms
memory: 3928kb
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