#SP0000016. Tần suất nguyên tố (Prime Frequency)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Tần suất nguyên tố (Prime Frequency)
Prime Frequency
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Given a string containing only the decimal digits 0–9, uppercase letters A–Z, and lowercase letters a–z, a character's frequency is its number of occurrences. Collect every character whose frequency is prime (greater than with exactly two positive divisors) and sort the resulting characters by increasing ASCII code. Digits precede uppercase letters, which precede lowercase letters. Use empty if no character qualifies.
Input
One nonempty line contains string , consisting of the specified letters and digits.
Output
Print exactly Case 1: followed by the sorted qualifying characters, or empty if there are none. The number 1 is the label of the sole data set in this adaptation.
Subtasks
- Subtask 1 (20 points): ; all characters belong to
0–9,A–Zora–z. - Subtask 2 (30 points): ; all characters belong to
0–9,A–Zora–z. - Subtask 3 (50 points): ; all characters belong to
0–9,A–Zora–z.
Examples
Input
ABCC
Output
Case 1: C
Explanation
A and B occur once each, while C occurs twice. Only frequency is prime, so the result is Case 1: C.
Input
AABBBBDDDDD
Output
Case 1: AD
Explanation
A appears twice, B four times, and D five times. Frequencies and are prime, whereas is composite, so the sorted answer is AD.
Input
ABCDFFFF
Output
Case 1: empty
Explanation
Each of A, B, C, D occurs once and F occurs four times. Since neither nor is prime, no character qualifies; print empty.