Here, if T-1, we have: the number of digits a prime number should have is 3 and 0 should be repeating number in it. Since, there are many three-digits prime numbers contain O's, but the numbers which are having 0's in it are 101, 103, 107, 109, 307, 40 601, 607, 701, 709, 809, and 907 and so it's sum will be 6883. And, if T-2, we have: Advisory CH653356 the number of digits a prime number should have is 4 and 1 should be repeating number in it. Since, there are many four-digits prime numbers contain 1's, but the numbers which are having maximum 1's in it are 1117, 1151, 1171, 1181, 1511, 1811,2111, 4111, and 8111 and so it's sum will be 22275. Hence, it will print 6883 and 22275 as an output. Sample Input2: 4 42 43 50 54 Sample Output2: 2221 46214 450046 44449 Explanation2: Here, if T=1, we have: TIME Deloitte soryC? 401, 409, 503, 509 the number of digits a prime number should have is 4 and 2 should be repeating number in it. Since, there are many four-digits prime numbers contain 2's, but there is only one number which is having maximum 2's in it i.e., 2221 and so it's sum will be 2221. And, if T-2, we have: the number of digits a prime number should have is 4 and 3 should be repeating number in it. Since, there are many four-digits prime numbers contain 3's, but the numbers which are having maximum 3's in it are 2333, 3313 3323, 3331, 3343 3373, 3433, 2922 5222 ond 7333 and so it's sum will be 16214

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Please code the question in Java or Python or C or C++ or R or Javascript ( any one of the following languages)
Here, if T-1, we have:
the number of digits a prime number should have is 3 and 0 should be repeating number in it.
Since, there are many three-digits prime numbers contain 0's, but the numbers which are having
601, 607, 701, 709, 809, and 907 and so it's sum will be 6883.
And, if T-2, we have:
Hence, it will print 6883 and 22275 as an output.
Sample Input2:
4
42
43
50
54
the number of digits a prime number should have is 4 and 1 should be repeating number in i
Since, there are many four-digits prime numbers contain 1's, but the numbers which are having maximum 1's in it are 1117, 1151, 1171, 1181, 1511, 1811, 2111,
4111, and 8111 and so it's sum will be 22275.
dvisory CH65335
Sample Output2:
2221
46214
450046
44449
dol
Explanation2:
Here, if T=1, we have:
TIME
MEGSCH653356
sorvema's in it are 101, 103, 107, 109, 306533
401, 409, 503, 509,
the number of digits a prime number should have is 4 and 2 should be repeating number in it.
Since, there are many four-digits prime numbers contain 2's, but there is only one number which is having maximum 2's in it i.e., 2221 and so it's sum will be
2221.
And, if T=2, we have:
the number of digits a prime number should have is 4 and 3 should be repeating number in it.
Since, there are many four-digits prime numbers contain 3's, but the numbers which are having maximum 3's in it are 2333, 3313, 3323, 3331, 3343 3373, 3433,
3533, 3733, 3833, 5333, and 7333 and so it's sum will be 46214.
Transcribed Image Text:Here, if T-1, we have: the number of digits a prime number should have is 3 and 0 should be repeating number in it. Since, there are many three-digits prime numbers contain 0's, but the numbers which are having 601, 607, 701, 709, 809, and 907 and so it's sum will be 6883. And, if T-2, we have: Hence, it will print 6883 and 22275 as an output. Sample Input2: 4 42 43 50 54 the number of digits a prime number should have is 4 and 1 should be repeating number in i Since, there are many four-digits prime numbers contain 1's, but the numbers which are having maximum 1's in it are 1117, 1151, 1171, 1181, 1511, 1811, 2111, 4111, and 8111 and so it's sum will be 22275. dvisory CH65335 Sample Output2: 2221 46214 450046 44449 dol Explanation2: Here, if T=1, we have: TIME MEGSCH653356 sorvema's in it are 101, 103, 107, 109, 306533 401, 409, 503, 509, the number of digits a prime number should have is 4 and 2 should be repeating number in it. Since, there are many four-digits prime numbers contain 2's, but there is only one number which is having maximum 2's in it i.e., 2221 and so it's sum will be 2221. And, if T=2, we have: the number of digits a prime number should have is 4 and 3 should be repeating number in it. Since, there are many four-digits prime numbers contain 3's, but the numbers which are having maximum 3's in it are 2333, 3313, 3323, 3331, 3343 3373, 3433, 3533, 3733, 3833, 5333, and 7333 and so it's sum will be 46214.
Given two numbers, N and d as an input. Print the sum of all N digit prime numbers where the digit da
If, for example, N=4 and d=0, then the sum of all possible numbers is 67061, which includes 1009, ars the most.
165
9001, and 9007.
There are many four-digit prime numbers that contain single O's in them but they are not taken into consideration as they do not have'
number of times.
, 3001, 4001, 4003, 4007, 5003, 5009, 6007, 7001, 8009,
Read the input from STDIN and print the output to STDOUT Do not print arbitrary strings anywhere in the program, as these contribute to the standard output and
test cases will fail.
Advoccurring maximum
Constraints:
N (1 ≤N≤ 10¹8)
2024
Input Format:
The first line of input contains T, number of test cases.
The next T lines of input contain, N and d, denoting the number of digits a prime number should have and a number that should be repeating in it, respectively. N
and d are separated by a single white-space.
Sample Input1:
2
30
41
Output Format:
The output must display the sum of all N digit prime numbers where the digit d appears the most. print the output in T separate lines as per the order of input
Sample Output1:
6883
22275
Explanation 1:
Here, if T=1, we have:
Delo
have is 3 and 0 should be repeating number in it.
Transcribed Image Text:Given two numbers, N and d as an input. Print the sum of all N digit prime numbers where the digit da If, for example, N=4 and d=0, then the sum of all possible numbers is 67061, which includes 1009, ars the most. 165 9001, and 9007. There are many four-digit prime numbers that contain single O's in them but they are not taken into consideration as they do not have' number of times. , 3001, 4001, 4003, 4007, 5003, 5009, 6007, 7001, 8009, Read the input from STDIN and print the output to STDOUT Do not print arbitrary strings anywhere in the program, as these contribute to the standard output and test cases will fail. Advoccurring maximum Constraints: N (1 ≤N≤ 10¹8) 2024 Input Format: The first line of input contains T, number of test cases. The next T lines of input contain, N and d, denoting the number of digits a prime number should have and a number that should be repeating in it, respectively. N and d are separated by a single white-space. Sample Input1: 2 30 41 Output Format: The output must display the sum of all N digit prime numbers where the digit d appears the most. print the output in T separate lines as per the order of input Sample Output1: 6883 22275 Explanation 1: Here, if T=1, we have: Delo have is 3 and 0 should be repeating number in it.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY