QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#129337 | #6138. Function and Function | Energy_is_not_over# | AC ✓ | 23ms | 3460kb | C++17 | 1.5kb | 2023-07-22 15:37:27 | 2023-07-22 15:37:28 |
Judging History
answer
//
// Created by Barichek on 22.07.2023 10:34:30
//
#include <bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define all(a) a.begin(), a.end()
#define len(a) (int) (a.size())
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
#ifdef Energy_is_not_over
#define DEBUG for (bool ____DEBUG = true; ____DEBUG; ____DEBUG = false)
#define LOG(...) print(#__VA_ARGS__" ::", __VA_ARGS__) << endl
template<class ...Ts>
auto &print(Ts ...ts) { return ((cerr << ts << " "), ...); }
#else
#define DEBUG while (false)
#define LOG(...)
#endif
const int max_n = -1, inf = 1000111222;
int ff(int xx)
{
if (xx==8){
return 2;
}
if (xx==0 || xx==4 || xx==6 || xx==9){
return 1;
}
return 0;
}
int f(int x)
{
if (x==0){
return 1;
}
int res=0;
while (x){
res+=ff(x%10);
x/=10;
}
return res;
}
void solve()
{
int x,k;
cin>>x>>k;
for (int i=0;i<10&&k>0;i++){
x=f(x);
k--;
}
if (k%2==1){
x^=1;
}
cout<<x<<"\n";
}
int main() {
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
int tests;
cin>>tests;
while (tests--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3460kb
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: 23ms
memory: 3428kb
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