J.Prime

J.Prime

maybe也是水题

题目描述

Give you a positive integer nn, can you find four prime numbers aa, bb, cc and dd satisfied that a + b + c + d = n and minimizing min(a, b, c, d)?

a, b, c, d are allowed to be the same prime number.

输入格式

The first line contains an integer T for test cases.

Next T lines, each line has an integer n.

1≤T≤105

1≤n≤231

输出格式

For each test case, output an integer to represent the minimum value of min(a, b, c, d)min(a,b,c,d). If it does not exist, you just need to output -1.

输入输出样例

输入 #1

2
1
8

输出 #1

-1
2

#include<bits/stdc++.h>

using namespace std;
#define ll long long

int main()
{
	int t;
	ll n;//开long long
	cin>>t;
	while(t--)
	{
		cin>>n;
		if(n<8) cout<<"-1"<<endl;
		else cout<<"2"<<endl;
	}
	return 0;
}

int的取值范围是-231 ~231-1 ,也就是 -2147483648 ~ - 2147483647
所以 n 要开long long(我们一开始就是因为没开long long 错的)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值