Advertisement
arjunarul

Untitled

Jun 17th, 2019
2,229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. This is an example statement in markdown. This is the statement of the problem [TANDC](https://codechef.com/problems/TANDC) on CodeChef. The main statement starts with the next paragraph. Please make sure to remove this paragraph from your statement before publishing your problem. If your problem doesn't contain Subtasks, you should remove the section subtask too. We are using markdown the syntax of which can be seen [at](https://github.com/showdownjs/showdown/wiki/Showdown's-Markdown-syntax). We request you to not use any HTML tags in the statement, e.g. no p, ul, li, pre, br or b tags. If you face any issue, please contact admins or email us at help@codechef.com.
  2.  
  3. Tracy is teaching Charlie maths via a game called $N$-Cube, which involves three sections involving $N$.
  4.  
  5. Tracy gives Charlie a number $N$, and Charlie makes a list of $N$-th powers of integers in increasing order $1^N, 2^N, 3^N, \dot, \text{so on}$. This teaches him exponentiation.
  6.  
  7. Then Charlie performs the following subtraction game $N$ times: Take all pairs of consecutive numbers in the list and take their difference. These differences then form the new list for the next iteration of the game. Eg, if $N$ was 6, the list proceeds as $[1, 64, 729, 4096 ... ]$ to $[63, 685, 3367 ...]$, and so on $5$ more times.
  8.  
  9. After the subtraction game, Charlie has to correctly tell Tracy the $N$-th element of the list. This number is the *value of the game*.
  10.  
  11. After practice Charlie became an expert in the game. To challenge him more, Tracy will give two numbers $M$ (where $M$ is a prime) and $R$ instead of just a single number $N$, and the game must start from $M_R - 1$ instead of $N$. Since the *value of the game* can now become large, Charlie just have to tell the largest integer $K$ such that $M_K$ divides this number. Since even $K$ can be large, output $K$ modulo 1000000007 ($10^9 + 7$).
  12.  
  13. ###Input:
  14.  
  15. - First line will contain $T$, number of testcases. Then the testcases follow.
  16. - Each testcase contains of a single line of input, two integers $M, R$.
  17.  
  18. ###Output:
  19. For each testcase, output in a single line answer given by Charlie to Tracy modulo 1000000007.
  20.  
  21. ###Constraints
  22. - $1 \leq T \leq 1000$
  23. - $2 \leq M \leq 10^9$
  24.  
  25. ###Subtasks
  26. - 30 points : $1 \leq R \leq 10000$
  27. - 70 points : $1 \leq R \leq 10^9$
  28.  
  29. $M$ is a prime number
  30.  
  31. ###Sample Input:
  32. 1
  33. 2 2
  34.  
  35. ###Sample Output:
  36. 1
  37.  
  38. ###EXPLANATION:
  39. This list is :
  40. $[1,8,27,64,125..] -> [7,19,37,61..] -> [12,18,24..] -> [6,6,6..]$. Number of times 2 divides 6 is 1. Hence the answer is 1.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement