CF1244A.Pens and Pencils

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Tomorrow is a difficult day for Polycarp: he has to attend aa lectures and bb practical classes at the university! Since Polycarp is a diligent student, he is going to attend all of them.

While preparing for the university, Polycarp wonders whether he can take enough writing implements to write all of the lectures and draw everything he has to during all of the practical classes. Polycarp writes lectures using a pen (he can't use a pencil to write lectures!); he can write down cc lectures using one pen, and after that it runs out of ink. During practical classes Polycarp draws blueprints with a pencil (he can't use a pen to draw blueprints!); one pencil is enough to draw all blueprints during dd practical classes, after which it is unusable.

Polycarp's pencilcase can hold no more than kk writing implements, so if Polycarp wants to take xx pens and yy pencils, they will fit in the pencilcase if and only if x+y≤kx + y \le k.

Now Polycarp wants to know how many pens and pencils should he take. Help him to determine it, or tell that his pencilcase doesn't have enough room for all the implements he needs tomorrow!

Note that you don't have to minimize the number of writing implements (though their total number must not exceed kk).

明天对波利卡普来说是艰难的一天:他需要在大学参加 aa 节理论课和 bb 节实践课!由于波利卡普是一名勤奋的学生,他打算全部参加。

在为大学做准备时,波利卡普思考自己是否能携带足够数量的书写工具,以便记完所有理论课笔记,并完成所有实践课所需的绘图。波利卡普用钢笔记录理论课(他不能用铅笔记录理论课!);一支钢笔可记录 cc 节理论课,之后墨水耗尽。在实践课中,波利卡普用铅笔绘制蓝图(他不能用钢笔绘制蓝图!);一支铅笔足以完成 dd 节实践课的所有绘图,之后即报废。

波利卡普的笔袋最多可容纳 kk 件书写工具,因此若他想携带 xx 支钢笔和 yy 支铅笔,则它们能装入笔袋当且仅当 x+y≤kx + y \le k。

现在波利卡普想知道他应携带多少支钢笔和多少支铅笔。请帮助他确定这一数量,或告知他笔袋的空间不足以容纳他明天所需的所有书写工具!

注意:你无需最小化书写工具的总数量(但其总数不得超过 kk)。

输入格式

The first line of the input contains one integer tt (1≤t≤1001 \le t \le 100) — the number of test cases in the input. Then the test cases follow.

Each test case is described by one line containing five integers aa, bb, cc, dd and kk, separated by spaces (1≤a,b,c,d,k≤1001 \le a, b, c, d, k \le 100) — the number of lectures Polycarp has to attend, the number of practical classes Polycarp has to attend, the number of lectures which can be written down using one pen, the number of practical classes for which one pencil is enough, and the number of writing implements that can fit into Polycarp's pencilcase, respectively.

In hacks it is allowed to use only one test case in the input, so t=1t = 1 should be satisfied.

输入的第一行包含一个整数 tt(1≤t≤1001 \le t \le 100),表示输入中测试用例的数量。随后是各测试用例。

每个测试用例由一行描述,该行包含五个以空格分隔的整数 aa、bb、cc、dd 和 kk(1≤a,b,c,d,k≤1001 \le a, b, c, d, k \le 100),分别表示 Polycarp 需要参加的讲座数量、需要参加的实践课数量、一支钢笔能记录的讲座数量、一支铅笔能应付的实践课数量,以及 Polycarp 的铅笔盒所能容纳的书写工具总数。

在 hack 中,输入仅允许包含一个测试用例,因此必须满足 t=1t = 1。

输出格式

For each test case, print the answer as follows:

If the pencilcase can't hold enough writing implements to use them during all lectures and practical classes, print one integer −1-1. Otherwise, print two non-negative integers xx and yy — the number of pens and pencils Polycarp should put in his pencilcase. If there are multiple answers, print any of them. Note that you don't have to minimize the number of writing implements (though their total number must not exceed kk).

对于每个测试用例,按如下方式输出答案:

如果笔袋无法容纳足够数量的书写工具,以供所有理论课和实验课使用,则输出一个整数 −1-1。否则,输出两个非负整数 xx 和 yy —— 分别表示 Polycarp 应放入笔袋中的钢笔数量和铅笔数量。若存在多个可行解,输出任意一个即可。注意:你无需最小化书写工具的总数(但其总数不得超过 kk)。

输入输出样例

  • 输入#1

    3
    7 5 4 5 8
    7 5 4 5 2
    20 53 45 26 4

    输出#1

    7 1
    -1
    1 3

说明/提示

There are many different answers for the first test case; x=7x = 7, y=1y = 1 is only one of them. For example, x=3x = 3, y=1y = 1 is also correct.

x=1x = 1, y=3y = 3 is the only correct answer for the third test case.

第一个测试用例有多种不同的答案;x=7x = 7,y=1y = 1 只是其中之一。例如,x=3x = 3,y=1y = 1 也是正确的。

第三个测试用例的唯一正确答案是 x=1x = 1,y=3y = 3。

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

首页