QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#94064#6138. Function and FunctionCSU2023#AC ✓9ms3480kbC++14846b2023-04-05 09:56:512023-04-05 09:56:53

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-05 09:56:53]
  • Judged
  • Verdict: AC
  • Time: 9ms
  • Memory: 3480kb
  • [2023-04-05 09:56:51]
  • Submitted

answer

#include<bits/stdc++.h>
#define LL long long
#define mk make_pair
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
const int f[10] = {1,0,0,0,1,0,1,0,2,1};
inline int read(){
	int v = 0,c = 1;char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-') c = -1;
		ch = getchar();
	}
	while(isdigit(ch)){
		v = v * 10 + ch - 48;
		ch = getchar();
	}
	return v * c;
}
inline int getf(int n){
	int sum = 0;
	int now = n;
	while(now){
		sum += f[now % 10];
		now /= 10;	
	}
//	printf("%d %d\n",n,sum);
	return sum;
}
inline int work(int n,int k){
	if(!k) return n;
	if(n == 1) return !(k & 1);
	if(n == 0) return k & 1;
	return work(getf(n),k - 1);
}
int main(){
	int T = read();
	while(T--){
		int n = read(),k = read();
		printf("%d\n",work(n,k));	
	}
    return 0;
}




Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3480kb

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: 9ms
memory: 3464kb

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