Time limit: 0.5 seconds Memory limit: 256 MB Prof. Baqir, who is a keen user, went to…
- User
Time limit: 0.5 seconds Memory limit: 256 MB Prof. Baqir, who is a keen user, went to his calculator. The first number 1 is written on his calculator. Since he is born, he can only do two things: either he multiplies the number written on the calculator by 5, or he divides the number written on the calculator by 2. Then he reads the number written on the calculator. Because he asked you to give him the final number displayed on his calculator in a legible manner after receiving the operations. It is a readable number for the professor a b x 1 0 c a b ×10 c May it be in it a a is a natural number and b , c b, c are integers and the following conditions are met:
1 0 9 ≤ b , c ≤ 1 0 9 -10 9 ≤ b, c ≤ 10 9
1 ≤ a ≤ 1 0 9 1≤a≤10 9
input The first line of the input contains the number n n represents the number of operations that the professor performed. in each of n n The next line is a number that represents what the professor does. If this number is 2, it means that the professor has divided the number written on the calculator by 2, and if this number is 5, it means that the professor has multiplied the number written on the calculator by 5. 1 ≤ n ≤ 10
000 1≤n≤10 000
output The only output line should contain three numbers a , b , c Let a, b, c be integers and:
1 ≤ a ≤ 1 0 9 1≤a≤10 9
1 0 9 ≤ b , c ≤ 1 0 9 -10 9 ≤ b, c ≤ 10 9
Example Sample entry 1 2 5 2 Plain text Sample output 1 52-1 Plain text Sample input 2 2 5 5 Plain text Sample output 2 25 1 0
- Assistant
To solve this problem, you need to perform the operations on the initial number
N(which is 1) as per the given operations, and then express the finalNin the form ( N = \frac{a \times 10^c}{b} ) wherea,b, andcare integers satisfying the given constraints.Here's how you can approach it:
-
Compute
N: Start withN = 1. For each operation:- If the operation is
5, multiplyNby5. - If the operation is
2, divideNby2.
- If the operation is
-
Express
Nas a fraction: IfNis not an integer, express it as a fraction ( \frac{p}{q} ) in its simplest form. -
Find
a,b, andc: Choose integer values ofa,b, andcsuch that:- ( N = \frac{a \times 10^c}{b} )
- ( 1 \leq a \leq 10^9 )
- ( -10^9 \leq b, c \leq 10^9 )
- All values are integers.
Since the constraints are generous, you can pick
c = 0and directly seta = pandb = q, ensuring they are within constraints.Sample Solution for Sample Input 1:
2 5 2-
Compute
N:- Start with
N = 1. - Multiply by
5:N = 5. - Divide by
2:N = 2.5.
- Start with
-
Express
Nas a fraction:- ( N = \frac{5}{2} )
-
Choose
a = 5,b = 2,c = 0(since ( N = \frac{5 \times 10^0}{2} )).
Sample Output 1:
5 2 0Sample Solution for Sample Input 2:
2 5 5-
Compute
N:- Start with
N = 1. - Multiply by
5:N = 5. - Multiply by
5:N = 25.
- Start with
-
Nis already an integer, so seta = 25,b = 1,c = 0.
Sample Output 2:
25 1 0Final Answer:
5 2 0 -