#Lutece3349. Simple Counting
Simple Counting
Description
Given an array whose length is and two integers and . In one operation, you can choose an index () and add either or to .
For an unordered integer pair (), if you can perform a finite number of times (which can be zero) of the operation, resulting in , then the pair is good.
Count the number of good unordered pairs in the array.
Input
The first line contains three integers ().
The second line contains integers (), indicating the array.
Output
Output an integer indicating the answer.
Samples
6 56482 114514
6 6 6 6 6 6
15
3 7 2
11 21 7
3
6 1 1
58 45 15 25 26 9
15
Note
For the second example, all pairs meet the requirements. For example, with the pair , choosing as 1 and adding , after performing this operation five times, we have and ; thus, the pair satisfies the requirement. Please note that and are considered the same pair.
Resources
电子科技大学第十五届 ACM 趣味程序设计竞赛