Prime String
Practice
4.1 (17 votes)
Ad Hoc
Approved
Basic programming
Easy
Implementation
Open
Problem
83% Success 7276 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Alice has just learnt about primeStrings. A string is a primeString if the number of distinct alphabets used in the string is a prime and also the number of occurrences of each alphabet in the string is also a prime.
Given a String you need to tell if it is a primeString or not.

Input:

First line contains T which is the number of test cases.
T lines follow each containing a string of characters 'a' to 'z'.

Output:

For each input, output "YES" if the number is a primeString or "NO" if not.

Constraints:

  • \(1 ≤ T ≤ 10\)
  • \(1 ≤ Length\; of\; string ≤ 10\)5

Scoring:

  • \(1 ≤ T ≤ 10, 1 ≤ Length\; of\; string ≤ 10\; (20 pts)\)
  • \(1 ≤ T ≤ 10, 1 ≤ Length\; of\; string ≤ 1000 \;(30 pts)\)
  • \(1 ≤ T ≤ 10, 1 ≤ Length\; of\; string ≤ 10\)5 \((50 pts)\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
16 votes
Tags:
ApprovedBasic ProgrammingEasyMathOpenPrimality testSieve
Points:20
524 votes
Tags:
ApprovedData StructuresEasyHiringSieve
Points:20
52 votes
Tags:
ApprovedEasyMathOpenPrimality test