Bode and Magic Number (Removed due to some problem in test cases)

0

0 votes
Problem

Doge desperately wants the head key from bode to find omega key. Fortunately, Bode found a safe shelf in Locke house where he can hide the head key. The speciality of the shelf is that it only gets locked or unlocked by one magic number. So,  Bode wants you to find that magic number.


Bode has a secret scroll which consists of a sequence of characters. You can find the magic number by summing up all the character's ASCII values but the only condition is that adjacent characters repeating more than one times should be counted as one. Moreover, the magic number should be modulo with the ASCII value of characters present in the longest substring of the same character.

 

INPUT:

First line contains an integer T denoting number of testcases.

Second line contains an integer N (1<= N <= 10^4)  length of a character.

Third  line contains string with all lower case character.

OUTPUT:

A magic number for all the test cases

 

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

here 2 cases are given,

1st test case: length of the string is 3 and the string is "abc"

hence, a+b+c = 294 % 97('a'  has highest consecutive frequency)  = 22

2nd test case: length of the string is 8 and the string is "aasdeeer"

similarly, 430 % 102 ('e'  has highest consecutive frequency)  =  22

Editor Image

?