QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#101325#6138. Function and Functiondiyitibu#TL 0ms3352kbC++14449b2023-04-29 10:17:572023-04-29 10:18:01

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-29 10:18:01]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3352kb
  • [2023-04-29 10:17:57]
  • 提交

answer

#include <iostream>
#include <bits/stdc++.h>

using namespace std ;

int bg[] = {1 ,0 , 0 , 0 , 1 , 0 , 1 , 0 , 2 , 1} ;

int get(int x) {
	int ans = 0 ;
	while(x) {
		ans += bg[x % 10] ;
		x /= 10 ; 
	}	
	return ans ; 
}
int main(void) {
	int T ;
	cin >>T;
	while(T --) {
		int x , k ;
		cin >>x >> k ;
		while(k && x != 0 && x != 1) x = get(x) , k -- ;
		if(k) {
			if(k & 1) x = get(x) ; 
		} 
		cout <<x <<"\n" ; 
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3352kb

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
1
743551976
0
1
464290891
0
0
1
791182580
0
402374924
0
0
2
0
0
1
2
1
0
0
0
3
0
0
0
1
0
0
0
0
2
0
0
1
0
0
0
0
0
0
0
0
0
0
55349255
486354015
1
0
0
0
0
0
1
0
0
0
0
9
0
0
0
0
0
0
0
0
0
1
0
0
0
0
25600152
0
0
0
22903397
705086250
771453912
0
1
0
0
0
0
1
0
1
2
0
0
0
0
1
0
6
3
3
0
0
0
0
0
86248...

result: