A. Pens and Pencils

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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≤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).

Input

The first line of the input contains one integer tt (1≤t≤1001≤t≤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≤a,b,c,d,k≤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.

Output

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).

Example

input

Copy

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

output

Copy

7 1
-1
1 3

Note

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.

解题说明:本题是一道模拟题,按照题目意思求解即可。

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main() {
	int n, i, a, b, c, d, k, ans, ans1;
	scanf("%d", &n);
	for (i = 0; i < n; i++) 
	{
		scanf("%d %d %d %d %d", &a, &b, &c, &d, &k);
		if (a % c == 0) 
		{
			ans = a / c;
		}
		else 
		{
			ans = a / c + 1;
		}
		if (b % d == 0) 
		{
			ans1 = b / d; 
		}
		else 
		{
			ans1 = b / d + 1; 
		}
		if (ans + ans1 <= k) 
		{
			printf("%d %d\n", ans, ans1);
		}
		else 
		{
			printf("%d\n", -1);
		}
	}
	return 0;
}
发布了1729 篇原创文章 · 获赞 371 · 访问量 273万+

猜你喜欢

转载自blog.csdn.net/jj12345jj198999/article/details/102651678