Jungerstein's Math Training Room: 5. Cat back
Description:
Jo-jo is a lonely man with a clever and eternally living cat. However, the cat feels Jo-jo is too lonely, and it decides to leave him; but it also hates to leave him forever.
Then the cat decides to revisit Jo-jo according to the following fixed scheme.
- It leaves on the t-th day of the week (1 to 7 inclusive).
- Its first revisit with Jo-jo is p days later.
- The time span between revisits are in a geometric sequence.
For example
- First revisit: p days after its leaving.
- Second revisit: p q days after the first revisit.
- Third revisit: p q^2 days after the second revisit, and so on.
Please calculate on which day of the week (still 1 to 7, inclusive) the cat revisits Jo-jo for the n-th time.
The numbers p, q, t, n are all positive integers. As usual, t is given as integer, but **p, q, and n are given in a string represented in decimal ways. The length of such strings are all divisible by 3, padded with leading zeros. ** (This format might be a hint, but also might be a misleading to the solution. )
Restrictions: t must be in [1, 2, 3, 4, 5, 6, 7]; the length of any string p, q, or n is guaranteed not to exceed 10002. Since the strings are too long, _large random tests do not reveal their values in test messages. _
Well, corner cases will also be tested, but all numbers are guaranteed to be positive integers, and the strings are always in the described format.
Warning
NEVER even try to calculate the exact numbers involved. The numbers are far too huge.
You have to find out the patterns to solve the problem.
Clarification
The time span is counted as difference of moments. For example, between today (the eighth of August) and tomorrow (the ninth) there is 1 day.
Example Test
p = '001', q = '002', t = 2, n = '004'
- Today the cat leaves. It is Tuesday (well, for example; you can read it anyway you want, and it will not change your result).
- One day later, it will be the cat's first revisit -- Wednesday.
- Two days later, the second revisit -- Friday.
- Four days later, the third revisit -- Tuesday.
- Eight days later, the fourth revisit -- Wednesday.
So please return 3 as integer.
Similar Kata:
Stats:
Created | Aug 8, 2017 |
Published | Aug 8, 2017 |
Warriors Trained | 46 |
Total Skips | 0 |
Total Code Submissions | 75 |
Total Times Completed | 6 |
Python Completions | 6 |
Total Stars | 3 |
% of votes with a positive feedback rating | 0% of 1 |
Total "Very Satisfied" Votes | 0 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 1 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 6 kyu |