PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000151. Ada và biển số nguyên tố (Ada and Prime)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Ada và biển số nguyên tố (Ada and Prime)
Ada and Prime
Source: SPOJ — ADAPRIME
Version: Phước Hưng OJ Extended; one input file per judge run.
Problem Statement
Given a multiset of digits, count distinct primes obtainable by permuting all digits, with no leading zero. A single multiset is provided per PHOJ run.
Input
First line contains , second line the digits in .
Output
Print the number of distinct primes.
Subtask
- Subtask 1 (20 points): , .
- Subtask 2 (30 points): , .
- Subtask 3 (50 points): , .
Example
Input
5
1 2 0 8 9
Output
11
Explanation
The example follows the mathematical conditions and the specified output format.