QOJ.ac

QOJ

时间限制: 2.0 s 内存限制: 512 MB 总分: 100

#15797. 兔子的午餐

统计

Snuke 想给兔子们喂食。他为兔子们的午餐准备了以下食物:

  • $M$ 种胡萝卜。第 $i$ 种胡萝卜有 $m_i$ 个。
  • $N$ 种奇异果。第 $i$ 种奇异果有 $n_i$ 个。

种类用从零开始的连续整数进行编号。

兔子们的午餐必须遵守以下规则。首先,每只兔子必须吃一个胡萝卜和一个奇异果。其次,不允许有两只兔子吃完全相同的午餐(即,相同种类的胡萝卜和相同种类的奇异果)。求最多可以有多少只兔子吃上午餐。

由于输入数据量很大,请使用以下递推公式来生成 $m_i$ 和 $n_i$:

  • $m_0 = m0$
  • $m_{i+1} = (m_i \times 58 + md) \bmod (N + 1)$
  • $n_0 = n0$
  • $n_{i+1} = (n_i \times 58 + nd) \bmod (M + 1)$

输入格式

输入的第一行包含 6 个整数 $M, N, m0, md, n0, nd$。

数据范围

  • $1 \le M \le 2,500,000$
  • $1 \le N \le 2,500,000$
  • $0 \le m0, md \le N$
  • $0 \le n0, nd \le M$

输出格式

输出最多可以吃上午餐的兔子数量。

样例

输入样例 1

2 3 1 3 1 0

输出样例 1

2

输入样例 2

5 8 1 2 3 4

输出样例 2

19

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.