CF2230A.Optimal Purchase

入门

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

You have a group of nn students who need access to an online course. Two types of access keys are available in the store:

  1. Individual key: costs aa dollars and gives access to one student.
  2. Group key: costs bb dollars and gives access to a group of up to three students inclusive.

A group key can also be used for fewer students (one or two), and its price does not change.

Your task is to determine the minimum amount of money needed to provide access to the online course for all nn students.

你有一组 nn 名学生需要访问一门在线课程。商店中提供两种类型的访问密钥:

  1. 单人密钥:花费 aa 美元,可供一名学生使用。
  2. 团体密钥:花费 bb 美元,可供最多三名学生(含三名)共同使用。

团体密钥也可供较少的学生(一名或两名)使用,且其价格不变。

你的任务是确定为全部 nn 名学生提供在线课程访问权限所需的最少金额。

输入格式

The first line contains one integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases.

Each test case consists of one line containing three integers n,a,bn, a, b (1≤n,a,b≤1081 \le n, a, b \le 10^8) — the number of students, the cost of an individual key, and the cost of a group key.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 测试用例的数量。

每个测试用例由一行组成,包含三个整数 n,a,bn, a, b(1≤n,a,b≤1081 \le n, a, b \le 10^8)—— 学生人数、单把钥匙的费用以及团体钥匙的费用。

输出格式

For each test case, output one integer — the minimum amount of money needed to provide access to the online course for all nn students.

对于每个测试用例,输出一个整数——为全部 nn 名学生提供在线课程访问权限所需的最少金额。

输入输出样例

  • 输入#1

    9
    5 10 25
    4 10 50
    1 20 15
    1 10 25
    100000000 100 290
    2 10 15
    300 1 1
    4 10 12
    11 10 20

    输出#1

    45
    40
    15
    10
    9666666670
    15
    100
    22
    80

说明/提示

In the first example, you can buy 11 group key and 22 individual keys.

In the second example, you can buy 44 individual keys.

In the third example, you can buy 11 group key.

In the fourth example, you can buy 11 individual key.

在第一个例子中,你可以购买 11 个团体密钥和 22 个单独密钥。

在第二个例子中,你可以购买 44 个单独密钥。

在第三个例子中,你可以购买 11 个团体密钥。

在第四个例子中,你可以购买 11 个单独密钥。

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

首页