Given two numbers, N and d as an input. Print the sum of all N digit prime numbers where the digit d appears the most. If, for example, N=4 and d=0, then the sum of all possible numbers is 67061, which includes 1009, 2003, 3001, 4001, 4003, 4007, 5003, 5009, 6007, 7001, 8009, 9001, and 9007. 26 There are many four-digit prime numbers that contain single 0's in them but they are not taken into consideration as they do not have' number of times. 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 am test cases will fail. Delo, Adviccurring maximum 4 Constraints: N (1 ≤N≤10¹8) UU CH65335 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

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 in Java or C or C++ or C # or python 2 or 3 or R( Any one of the following)
Del
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.
Constraints:
N (1 ≤N≤ 10¹8)
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.
Delody Occurring maximum
Sample Input1:
2
30
41
Adv
Sample Output1:
6883
22275
SEES9
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.
Explanation 1:
Here, if T=1, we have:
, 3001, 4001, 4003, 4007, 5003, 5009, 6007, 7001, 8009,
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
00:
have is. and 0 should be repeating number in it.
Activate Windows
Transcribed Image Text:Del 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. Constraints: N (1 ≤N≤ 10¹8) 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. Delody Occurring maximum Sample Input1: 2 30 41 Adv Sample Output1: 6883 22275 SEES9 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. Explanation 1: Here, if T=1, we have: , 3001, 4001, 4003, 4007, 5003, 5009, 6007, 7001, 8009, 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 00: have is. and 0 should be repeating number in it. Activate Windows
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.
the number of digits a prime number should have is 4 and 1 should be repeating number in sorvax in it are 101, 103, 107, 109, 307
And, if T-2, we have:
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, 17)
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
dvisory CH65335
Sample Output2:
2221
46214
450046
44449
Explanation2:
Here, if T=1, we have:
sors CH653358
TIME
Deloitte
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. the number of digits a prime number should have is 4 and 1 should be repeating number in sorvax in it are 101, 103, 107, 109, 307 And, if T-2, we have: 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, 17) 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 dvisory CH65335 Sample Output2: 2221 46214 450046 44449 Explanation2: Here, if T=1, we have: sors CH653358 TIME Deloitte 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.
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