长安大学第三届ACM-ICPC程序设计竞赛 E题

链接: https://www.nowcoder.com/acm/contest/102/E
来源:牛客网

题目描述

PSacfc is a student majors in Communication Engineering, and Wireless Mobile System is his favorite course.
One day, when the teacher talked about Cellular Mobile Communication, he thought of a problem.
Given n regular hexagons, find the minimum number of sides exposed. A side of a regular hexagon exposed means no other hexagons’ sides coincided with it. One side can be coincided with no more than one another.
For example, the first situation has 3 hexagons with 12 sides exposed, and the second situation has 3 hexagons with 14 sides exposed.

Your task is to find the minimum number of sides exposed with n regular hexagons.

输入描述:

The first line contains an integer number T, the number of test cases.
itℎ of each next T lines contains an integer number n(1 ≤ n ≤ 109).

输出描述:

For each test case print a number, minimum number of sides exposed.
示例1

输入

3
3
4
7

输出

12
14
18
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--){
		long long n;
		cin>>n;
		long long ans=2*ceil(sqrt(12*n-3));
		printf("%lld\n",ans);
	}
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值