QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓

#14719. Planting Trees

Estadísticas

Little L likes planting trees.

Little L planted $d$ trees on both the left and right sides of the yard. On the left side, the $i$-th tree has a height of $x_i$ meters on the first day and grows $f_i$ meters each day. On the right side, the $i$-th tree has a height of $y_i$ on the first day and grows $g_i$ meters each day.

However, Little L does not want the trees to be too high. To keep things neat, for the tree numbered $i$, if its height reaches or exceeds $m_i$, he will prune it by $m_i$ meters until its height is less than $m_i$.

Now, Little L wants to know, for the tree numbered $i$, during the first $n_i$ days after planting, after performing pruning each day, how many days the left tree is shorter than the right tree.

Note: pruning is also performed on the first day.

Input

There is only one test case in each test file.

The first line contains a positive integer $d$ ($1 \le d \le 10^4$), denoting the number of trees on each side of the yard.

Each of the next $d$ lines contains six positive integers $f_i, x_i, g_i, y_i, n_i, m_i$ ($1 \le f_i, x_i, g_i, y_i, n_i, m_i \le 10^6$), with the meanings described above.

Output

Output $d$ lines, each line containing a non-negative integer, representing the number of days within $n_i$ days that the left tree is shorter than the right tree for the tree numbered $i$.

Example

Sample Input 1

1
7 4 6 3 3 4

Sample Output 1

2

Note

For the first sample, we count the first $3$ days:

Day $1$: The initial height of the tree on the left side of the road is $4$ meters, and the tree on the right is $3$ meters. The left tree exceeds the $4$-meter limit, so it is pruned. After pruning, the left tree is $0$ meters and the right tree is $3$ meters; the left is lower than the right.

Day $2$: The left tree is $7$ meters and the right tree is $9$ meters. They both exceed $4$ meters, so they are pruned. After pruning, the left tree is $3$ meters and the right tree is $1$ meter; the left is not lower than the right.

Day $3$: The left tree is $10$ meters and the right tree is $7$ meters. They both exceed $4$ meters, so they are pruned. After pruning, the left tree is $2$ meters and the right tree is $3$ meters; the left is lower than the right.

Therefore, the output is $2$.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#943EditorialOpenNew Editorial for Problem #14719KiharaToumaView

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.