#P15766. [JAG 2025 Summer Camp #2] Mix Condiments
[JAG 2025 Summer Camp #2] Mix Condiments
题目描述
You are working in the development department of Incredible Condiment Product Corporation. This company currently sells kinds of condiments numbered through . The condiment has acridity and sourness .
A recent market research revealed that consumers desire a new condiment of acridity and sourness , though none of the condiments has such taste. Here, you wonder whether such a condiment can be manufactured by mixing two of the condiments. If two condiments are mixed to create a new one, its acridity and sourness are the weighted means from the two. More precisely, by mixing gram of condiment and gram of condiment where and are any positive real numbers, the acridity and sourness of the new condiment become and , respectively.
Please find all the possible unordered pairs of condiments such that by mixing those two in some ratio, you can create a condiment of acridity and sourness .
输入格式
The input consists of a single test case of the following format.
$$\begin{aligned} & n \\ & a_1 \ s_1 \\ & a_2 \ s_2 \\ & \vdots \\ & a_n \ s_n \\ & x \ y \end{aligned} $$The first line contains an integer () representing the number of condiments that your company currently sells. Each of the following lines contains two integers and () representing the acridity and sourness of condiment . The last line contains two integers and () representing the acridity and sourness of the condiment that consumers desire.
It is guaranteed that for any ().
输出格式
Print the answer in the following format.
$$\begin{aligned} & m \\ & c_1 \ d_1 \\ & c_2 \ d_2 \\ & \vdots \\ & c_m \ d_m \end{aligned} $$is the number of all pairs of condiments such that by mixing those two in some ratio, you can create a condiment of acridity and sourness . and () are the numbers of condiments in each pair.
The pairs must be output in the lexicographical order. More precisely, for any and (), either of the following properties must hold.
- and
8
8 6
4 8
6 0
10 5
3 7
6 50
7 7
8 6
6 7
5
1 2
2 4
2 8
3 6
5 7
6
10 20
10 30
20 10
30 10
0 0
49 50
10 10
0