CF2233A.AI Project Development

入门

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Maxim and Nikita are working together on a project consisting of nn lines of code.

Maxim starts working immediately and writes at a speed of xx lines per hour until the very end.

Nikita has two options:

  • not use AI and write from the very beginning at a speed of yy lines per hour;
  • spend zz hours first setting up an AI agent, writing nothing during that time, and then write at a speed of 10⋅y10 \cdot y lines per hour.

Nikita makes this choice before work begins and does not change it later.

While Nikita is setting up the AI, he does not write any code at all, but Maxim continues working at the speed of xx lines per hour.

The project is considered completed as soon as Maxim and Nikita together have written at least nn lines of code. If the project can be completed before the AI setup ends, then the work ends at that moment.

Time is measured using full hours: if a project is completed in the middle of an hour, this hour is counted fully.

Nikita chooses whether to use AI or not.

Determine the minimum number of full hours after which the project will be completed.

马克西姆和尼基塔正在合作完成一个包含 nn 行代码的项目。

马克西姆立即开始工作,以每小时 xx 行的速度持续编写,直至项目结束。

尼基塔有两种选择:

  • 不使用人工智能(AI),从一开始便以每小时 yy 行的速度编写;
  • 先花费 zz 小时设置 AI 助手(此期间不编写任何代码),之后以每小时 10⋅y10 \cdot y 行的速度编写。

尼基塔在工作开始前即作出该选择,且之后不再更改。

在尼基塔设置 AI 期间,他完全不编写代码,但马克西姆仍以每小时 xx 行的速度持续工作。

当马克西姆与尼基塔共同编写的代码行数至少达到 nn 行时,项目即视为完成。若项目能在 AI 设置完成前就已达成目标,则工作在此时刻即告结束。

时间以整小时为单位计量:若项目在某个小时中途完成,该小时仍被计为完整的一小时。

尼基塔可自主决定是否使用 AI。

请确定项目完成所需的最少整小时数。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1001 \le t \le 100). The description of the test cases follows.

The only line of each test case contains four integers nn, xx, yy, and zz (1≤n,x,y,z≤10 0001 \le n, x, y, z \le 10\,000) — the number of lines in the project, Maxim's speed, Nikita's speed without AI, and the AI setup time, respectively.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1001 \le t \le 100)。随后是各测试用例的描述。

每个测试用例仅有一行,包含四个整数 nn、xx、yy 和 zz(1≤n,x,y,z≤10 0001 \le n, x, y, z \le 10\,000),分别表示项目中的代码行数、Maxim 的编码速度、Nikita 在不使用 AI 时的编码速度,以及 AI 的配置时间。

输出格式

For each test case, output one integer — the minimum number of full hours after which the project will be completed if Nikita acts optimally.

对于每个测试用例,输出一个整数——若尼基塔采取最优策略,项目完成所需的最少完整小时数。

输入输出样例

  • 输入#1

    10
    1 1 1 1
    2 1 1 5
    3 1 1 1
    110 10 9 1
    54 14 1 1
    30 8 1 13
    6 2 1 3
    82 4 5 7
    200 3 2 4
    76 211 743 432

    输出#1

    1
    1
    2
    2
    3
    4
    2
    8
    13
    1

说明/提示

In the first example, without using AI, Nikita and Maxim will write 22 lines of code in 11 hour, and since the project requires only 11 line to finish, it will be completed in 11 hour.

In the fourth example, Nikita spends the first hour setting up the AI, while Maxim writes 1010 lines during that time, and then during the next hour 10+9⋅10=10010 + 9 \cdot 10 = 100 lines of code are written, so the whole project can be completed in 22 hours.

在第一个例子中,如果不使用人工智能,尼基塔和马克西姆将在 1 小时内编写 22 行代码;而该项目仅需 11 行代码即可完成,因此将在 11 小时内完成。

在第四个例子中,尼基塔用第一小时配置人工智能,而马克西姆在此期间编写了 1010 行代码;随后在接下来的一小时内,共编写了 10+9⋅10=10010 + 9 \cdot 10 = 100 行代码,因此整个项目可在 22 小时内完成。

输入解题思路,AI测评打分。不知道怎么写?

首页