QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#227142#6138. Function and FunctionhanoTL 87ms3624kbC++14624b2023-10-26 23:33:242023-10-26 23:33:24

Judging History

你现在查看的是最新测评结果

  • [2023-10-26 23:33:24]
  • 评测
  • 测评结果:TL
  • 用时:87ms
  • 内存:3624kb
  • [2023-10-26 23:33:24]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pi pair<int,ll>
#define fi first
#define se second
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC target("avx2")

int cal(int x){
    int ret=0;
    while(x){
        int dg=x%10;
        if(dg==8){
            ret+=2;
        }
        if(dg==0||dg==4||dg==6||dg==9)ret++;
        x/=10;
    }
    return ret;
}

int rec(int x,int k){
    if(k==0)return x;
    return rec(cal(x),k-1);
}

int main(){
    int t;cin>>t;
    while(t--){
        int x,k;cin>>x>>k;
        cout<<rec(x,k)<<endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 87ms
memory: 3624kb

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: -100
Time Limit Exceeded

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
0
0
743551976
0
0
464290891
0
0
1
791182580
0
402374924
0
0
2
0
0
0
2
0
0
0
0
3
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
55349255
486354015

result: