Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Prime String

By Rifat_MU47 · Limits 2s, 512 MB

We know that a prime number is a number that is divisible only by itself and 11 (e.g. 2,3,5,7,112, 3, 5, 7, 11).

Alice has a string SS of size nn. She calls a string good if the sum of ASCII values of all characters is a prime number. For example, let she has a string "abbabb". Now the sum of the ASCII values of 'aa', 'bb',
and 'bb' is (97+98+98)=293(97+98+98) =293 — which is a prime number. Then we can consider the string "abbabb" as a good string.

Now your task is to help Alice to find out the string is good or not.


Each test contains multiple test cases. The first line contains the number of test cases t(1t100)t \hspace{.1cm} (1 \leq t \leq 100). The description of the test cases follows.

The first line of each test case contains only one integer n(1n100)n \hspace{.1cm} (1 \leq n \leq 100) — the length of the string.

The next line contains the string S(S=n)S \hspace{.1cm} (|S| = n). It is given that SS consists of both English uppercase and lowercase letters.


For each input first print "Case #X: " (where XX is the case number). Then, print "Yes" if the string is good, or, print "No". Always print without quotes.


Case #1: Yes
Case #2: No


S|S| denotes the length of SS.



    97% Solution Ratio

    steinumEarliest, Oct '20

    steinumFastest, 0.0s

    cloud007Lightest, 0 B

    bokaifShortest, 205B


    Login to submit

    Toph uses cookies. By continuing you agree to our Cookie Policy.