Raging Infernape solution codechef
Finally, Ash and Paul are against each other in the tournament. Battle is between Infernape and Electivire. Infernape just turned on his ability named “Blaze”. Now he is fired up. But there is a problem with Infernape’s Blaze. Even though it gives immense power to Infernape but he losses his mind and attacks everyone. To calm him down so that Infernape can use his ability while staying in control, Ash has to complete the following task.
You are given a Stringmade up of lowercase English alphabet. For a substring of , we define of as . Where is smallest substring of S that has atleast two substrings equal to (i.e. ). Now you pick a substring of string uniformly randomly and you have to print the expected power of the chosen substring. The answer can be represented as a ratio (i.e. / ) of two positive co-prime numbers and You have to print modulo .
Input: Raging Infernape solution codechef
- First line will contain , number of testcases. Then the testcases follow.
- Each testcase contains a single line of input, a string S.
Output: Raging Infernape solution codechef
For each testcase, output in a single line the expected power of chosen substring modulo 998244353.
Constraints Raging Infernape solution codechef
Sample Input: Raging Infernape solution codechef
Sample Output: Raging Infernape solution codechef
Valid X’s are, X(“a”) = “aba”, X(“b”) = “bab”, X(“ab”) = “abab”, X(“ba”) = “baba”, X(“aba”) = “ababa”. Expected Power is, (3 * 3 + 3 * 2 + 4 * 2 + 4 * 2 + 5 * 2) / 15 = 532396991.
Codechef is an platform built to programmers compete against others in the community and to improve their knowledge by facing various challenges. Challenges are categorised on the basis of their difficulty level , if your rating is above 2000 you are in top tier i.e, Division 3 and if your rating is between 2000 and 1600 you will be in tier 2 i.e, Division 3 and if your rating is below that you will be in lowest tier i.e, Division 3. You can improve your rating by successful submission with minimum penalty.
- Game of Primes solution codechef
- Books and Friends solution codechef
- Run It Back solution codechef
- Buy Masks solution codechef
- How I Met Your Mother solution codechef
Also Read : Neenade Naa song lyrics with English Translation