#abc263g. G - Erasing Prime Pairs
G - Erasing Prime Pairs
Score : points
问题描述
在黑板上有 个不同数值的整数。第 个数值是 ,并且被写了 次。
你可以尽可能多地重复以下操作:
- 选择黑板上两个整数 和 ,要求满足 是质数。擦除这两个整数。
找出该操作最多能执行多少次。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are integers with different values written on a blackboard. The -th value is and is written times.
You may repeat the following operation as many times as possible:
- Choose two integers and written on the blackboard such that is prime. Erase these two integers.
Find the maximum number of times the operation can be performed.
Constraints
- All are distinct.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3
3 3
2 4
6 2
Sample Output 1
3
We have , and is prime, so you can choose and to erase them, but nothing else. Since there are four s and three s, you can do the operation three times.
Sample Input 2
1
1 4
Sample Output 2
2
We have , and is prime, so you can choose and to erase them. Since there are four s, you can do the operation twice.
update @ 2024/3/10 11:08:26