Given a positive integer (call it N), a position in that integer (call it P), and...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given a positive integer (call it N), a position in that integer (call it P), and a transition integer (call it D). Transform N as follows: • If the Pth digit of N from the right is from 0 to 4, add D to it. Replace the P digit by the units digit of the sum. Then, replace all digits to the right of the Ph digit by 0. • If the ph digit of N from the right is from 5 to 9, subtract D from it. Replace the P digit by the leftmost digit of the absolute value of the difference. Then, replace all digits to the right of the pa digit by 0. Example 1: N = 7145032, P=2, D-8. The 2nd digit from the right is 3; add 8 to it (3+8=11), and replace the 3 with I to get 7145012. Replace the digits to the right by Os to get 7145010. Example 2: N = 1540670, P= 3, D=54. The 3rd digit from the right is 6; the absolute value of 6-54 is 48; replace with the 4 to get 1540470. Replace the digits to the right with Os to get 1540400. INPUT: There will be 5 sets of data. Each set contains 3 positive integers: N, P, and D. N will be less than 10¹5; P and D will be valid inputs. No input will cause an output to have a leading digit of 0. OUTPUT: Print the transformed number. The printed number may not have any spaces between the digits. SAMPLE INPUT: (http://www.datafiles.acsl.org/2020/contest1/jr-sample-input.txt) 124987 2 3 540670 3 9 7145042 2 8 124987 2 523 4386709 1 2 SAMPLE OUTPUT: 1. 124950 2. 540300 3. 7145020 4. 124950 5. 4386707 TEST INPUT: 4318762 4 3 72431685 1 7 123456789 7 8 9876543210 10 25 314159265358 8 428 TEST OUTPUT: 1. 4315000 2. 72431682 3. 121000000 4. 1000000000 5. 314140000000 TEST DATA Given a positive integer (call it N), a position in that integer (call it P), and a transition integer (call it D). Transform N as follows: • If the Pth digit of N from the right is from 0 to 4, add D to it. Replace the P digit by the units digit of the sum. Then, replace all digits to the right of the Ph digit by 0. • If the ph digit of N from the right is from 5 to 9, subtract D from it. Replace the P digit by the leftmost digit of the absolute value of the difference. Then, replace all digits to the right of the pa digit by 0. Example 1: N = 7145032, P=2, D-8. The 2nd digit from the right is 3; add 8 to it (3+8=11), and replace the 3 with I to get 7145012. Replace the digits to the right by Os to get 7145010. Example 2: N = 1540670, P= 3, D=54. The 3rd digit from the right is 6; the absolute value of 6-54 is 48; replace with the 4 to get 1540470. Replace the digits to the right with Os to get 1540400. INPUT: There will be 5 sets of data. Each set contains 3 positive integers: N, P, and D. N will be less than 10¹5; P and D will be valid inputs. No input will cause an output to have a leading digit of 0. OUTPUT: Print the transformed number. The printed number may not have any spaces between the digits. SAMPLE INPUT: (http://www.datafiles.acsl.org/2020/contest1/jr-sample-input.txt) 124987 2 3 540670 3 9 7145042 2 8 124987 2 523 4386709 1 2 SAMPLE OUTPUT: 1. 124950 2. 540300 3. 7145020 4. 124950 5. 4386707 TEST INPUT: 4318762 4 3 72431685 1 7 123456789 7 8 9876543210 10 25 314159265358 8 428 TEST OUTPUT: 1. 4315000 2. 72431682 3. 121000000 4. 1000000000 5. 314140000000 TEST DATA
Expert Answer:
Related Book For
Discrete Mathematics and Its Applications
ISBN: 978-0073383095
7th edition
Authors: Kenneth H. Rosen
Posted Date:
Students also viewed these mathematics questions
-
Given a positive integer n, generate a random permutation of the set {1, 2, 3, . . . , n}.
-
USE R-STUDIO AND ADD CODE Let {X} an ARIMA process (2,1,0) given by: (1 - 0.8B +0.25B)VXt = Zt {Zt}~WN(0,1) Determine the forecast function. g(h) = PnXn+hVh>
-
Given a positive integer number says n , write a java program to print the first n squared numbers recursively
-
Consider two industries in which firms hold the following market shares: Industry A: 25%, 20%, 18%, 15%, 8%, 7%, 4%, 2%, 1% Industry B: 30%, 10%, 9%, 8%, 8%, 8%, 8%, 6%, 6%, 5%, 2% What are the...
-
Locate the chiral carbon atoms, if any, in each molecule: o HOoGHGi.CHoH HOSCHO (b) HOCH2CHCCH2OH O CH3 (c) HOCCHCHC2Hs NH2
-
Sonat operated a natural gas company that included multiple compressor stations along a pipeline that spanned from Texas to Georgia. Many of the compressor stations included mercury metering. Sonat...
-
During the assembly of an exhaust valve, sufficient distance must be maintained between the valve tip and the cylinder wall. If \(85 \%\) of valve assemblies have the required distance, use Table 1...
-
Danielle Neylon has trouble keeping her debits and credits equal. During a recent month, Danielle made the following accounting errors: a. In preparing the trial balance, Danielle omitted a $7,000...
-
2) Convert the following signed numbers to decimal by using 2's complement. (a) 01111101 (b) 10000000 (c) 11111111 (d)00000000 (e) 11110101
-
An article in Electronic Packaging and Production (2002, Vol. 42) considered the effect of X-ray inspection of integrated circuits. The rads (radiation dose) were studied as a function of current (in...
-
Q. 4 (i) Two pulley running on parallel shafts 2 m apart are connected by a crossed belt. Calculate the length of the belt and angle of contact between the belt and each pulley if the pulley...
-
I need to borrow $5,000 for a car because it enables me to get a job as a traveling anvil seller. Larry the Loan Shark will loan me the $5,000 at an interest rate of 90%. Principle and interest are...
-
A person works and earns $ 2,535.00 but on a pay stub pays 6.5% to tax. How much money is left over after taxes? Explain
-
3. On January 1, an investment fund was opened with an initial balance of 5000. Just after the balance grew to 5200 on July 1, an additional 2600 was deposited. The annual effective yield rate for...
-
Assume that a robot systems constant failure and repair rates are 0.0004 failures per hour and 0.002 repairs per hour, respectively. Calculate the robot system steady-state unavailability and...
-
What Is The Most Important Skill A Competent Communicator Should Have? Of the six competencies that a competent communicator should have, which is the most important?
-
Calculate the average return, the standard deviation as well as a risk-adjusted return measure for Apple, Microsoft, Walt Disney, Oracle Corporation (ORCL), The Coca-Cola Company, Swiss...
-
Give an example of transitory income. What effect does this income have on the marginal propensity to consume?
-
Express these system specifications using the propositions p "The message is scanned for viruses" and q "The message was sent from an unknown system" together with logical connectives (including...
-
Find the smallest equivalence relation on the set {a, b, c, d, e} containing the relation {(a, b), (a, c), (d, e)}.
-
S = x1y1 + x2y2 + + xnyn, where x1, x2, . . . , xn and y1, y2, . . . , yn are orderings of two different sequences of positive real numbers, each containing n elements. a) Show that S takes its...
-
If you look at the light spectrum reflected from the surface of a DVD compared to the spectrum reflected from the surface of a CD, youll see that the rainbows from the DVD are more spread out, with...
-
Increasing the density of a material tends to increase the index of refraction. Does light travel faster in seawater or in fresh water?
-
Antireflection coatings for glass usually have an index of refraction that is less than that of glass. Explain how this permits a thinner coating.
Study smarter with the SolutionInn App