#P2236. [HNOI2002] 彩票

    ID: 1210 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2002各省省选平衡树湖南深度优先搜索,DFS概率论,统计

[HNOI2002] 彩票

Description

A set of lottery tickets is issued in a certain place. Each ticket displays the MM natural numbers from 11 to MM. A player may circle any NN distinct numbers among these MM numbers. Each player can buy only one ticket, and different players choose different sets.

Each draw picks two natural numbers XX and YY. If, on someone's ticket, the sum of the reciprocals of the NN selected natural numbers is exactly equal to XY\dfrac{X}{Y}, then they will receive a souvenir.

Given the draw result XX and YY, determine how many souvenirs must be prepared to ensure all winners can be awarded.

Input Format

The input contains exactly one line with four integers NN, MM, XX, YY separated by spaces.

Output Format

Output one line with the required number of souvenirs.

2 4 3 4
1

Hint

1X,Y1001 \leq X, Y \leq 100, 1N101 \leq N \leq 10, 1M501 \leq M \leq 50.

The input guarantees the output does not exceed 10510^5.

Translated by ChatGPT 5