Codeforces Round #791 (Div. 2) A.AvtoBuS复盘

Spring has come, and the management of the AvtoBus bus fleet has given the order to replace winter tires with summer tires on all buses.

You own a small bus service business and you have just received an order to replace nn tires. You know that the bus fleet owns two types of buses: with two axles (these buses have 4 wheels) and with three axles (these buses have 6 wheels).

You don't know how many buses of which type the AvtoBus bus fleet owns, so you wonder how many buses the fleet might have. You have to determine the minimum and the maximum number of buses that can be in the fleet if you know that the total number of wheels for all buses is n.

Input

The first line contains an integer t (1≤t≤1000) — the number of test cases. The following lines contain description of test cases.

The only line of each test case contains one integer n (1≤n≤1018) — the total number of wheels for all buses.

Output

For each test case print the answer in a single line using the following format.

Print two integers x and y (1≤x≤y) — the minimum and the maximum possible number of buses that can be in the bus fleet.

If there is no suitable number of buses for the given nn, print the number -1 as the answer.

Example

input

4
4
7
24
998244353998244352

output

1 1
-1
4 6
166374058999707392 249561088499561088

Note

In the first test case the total number of wheels is 4. It means that there is the only one bus with two axles in the bus fleet.

In the second test case it's easy to show that there is no suitable number of buses with 7 wheels in total.

In the third test case the total number of wheels is 24. The following options are possible:

  • Four buses with three axles.
  • Three buses with two axles and two buses with three axles.
  • Six buses with two axles.

So the minimum number of buses is 4 and the maximum number of buses is 6.

 

预备知识 :

1.n&1(n&1==1)表示奇数

2.T组测试内的循环内,使用continue直接开启下一组测试,而不是直接return 0 结束。

3.long long int 表示范围:19位, -9223372036854775808——9223372036854775807,对于一般的竞赛大数据输入,够用

4.long long int 可写成 long long,但一般自定义 typedef long long ll

思路分析 :

排掉奇数小于4的数,为什么?因为后续的操作是基于偶数的,
4以内存在偶数2,而2个轮胎不可以2轴4胎3轴6胎换。
接下来就是n>=4偶数,首先由于3轴6胎2轴4胎多出2个轮胎,
因此,在二者存在情况下,选择输出/6输出/4
但是,这样其他情况未免适用。由于一轴轮胎为2,因此我们先把
n>=4的偶数/2,表示剩下的数量,根据轴数商讨如何分配。
先输出/3的结果,但是考虑到如果轴数为2,2/3为0(整型)。就会出现
最小车数为0情况,实际上2完全可以换到2轴上。

为了解决这问题,采取(加2)/3的 
方式,加1例如2,8,加2例如4,10。如果刚好处于2的倍数与3的倍数之间,可以很好的选择
是否能选择/3,从而保证车数不会少1。
后面一个输出为最小值,为2轴的,直接/2,相当于未/2的原数直接/4。
 

代码实现  : 

 

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int T;
int main(){
	cin>>T;
	while(T--){
		ll n;
		cin>>n;
		if(n&1||n<4){//除掉奇数与小于4的数。 
			cout<<-1<<endl;
			continue;
		}
		n/=2;
		cout<<(n+2)/3<<" "<<n/2<<endl;
		 
	}
}

运行结果  : 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值