Sagar And Strings
All submissions for this problem are available.
When Sagar was in the 4th grade, his class teacher asked him a problem he hasn't been able to solve till date. The problem is as follows: Given a string S of length N how many substrings of the string S are also substrings of the string "....xyzabcdefghijklmnopqrstuvwxyzabc..."?
Can you help Sagar solve this problem?
Note: The string "....xyzabcdefghijklmnopqrstuvwxyzabc..." wraps around infinitely in both directions
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each testcase contains N denoting the length of the string and the second line of each testcase contains the string S.
S will be made of only lowercase alphabets.
For each test case, output the required answer
Testcase 1: The possible substrings are "a", "b", "c", "d", "ab", "bc", "cd", "abc", "bcd", "abcd".
|Tags||easy, kjcs16, modulo, strings, vedipen|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions