当前位置:网站首页>Haut OJ 1243: simple mathematical problems
Haut OJ 1243: simple mathematical problems
2022-07-05 05:17:00 【hunziHang】
Problem description :
Here we go again. 209 It's time to rush to answer math problems once a day , The last time cds It's hard , This time ykc Mengxin gave them a simple math problem , It's really simple
, Is to give you a rectangular area , Find its minimum perimeter , Is it simple , ha-ha , But they just couldn't figure out what I could do , I have to leave the problem to you .
Input :
In the first line, enter a number to represent the test instance t
Enter a number for each group of test cases s(1<=s<=10^9) Represents the area of the rectangle
Output :
Output the minimum perimeter of each test instance
The sample input :
1 24
Sample output :
20
Cause analysis :
Find the minimum perimeter , That is to find the minimum sum of two adjacent sides , It is similar to inequality , That is, the closer the two sides are equal , That is, the sum of two sides is the smallest , So you can square the area first +1( Because rounding down ); Then decrease downward to find Can be s Divisible data .
Solution :
#include<bits/stdc++.h>
using namespace std;
#define endl'\n'
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long t;
cin>>t;
while(t--)
{
long long s,l;
cin>>s;
l=sqrt(double(s))+1;
for(int i=l;i>0;i--)
if(s%i==0)
{
cout<<2*(i+s/i)<<endl;
break;
}
}
}
边栏推荐
- Solon Auth 认证框架使用演示(更简单的认证框架)
- Download xftp7 and xshell7 (official website)
- 2022 / 7 / 1 Résumé de l'étude
- Fragment addition failed error lookup
- win10虚拟机集群优化方案
- 质量体系建设之路的分分合合
- Vs2015 secret key
- Judge the position of the monster in the role under unity3d
- [to be continued] [UE4 notes] L1 create and configure items
- Unity parallax infinite scrolling background
猜你喜欢
[to be continued] [UE4 notes] L1 create and configure items
TF-A中的工具介绍
[trans]: spécification osgi
Collapse of adjacent vertical outer margins
Use of snippets in vscode (code template)
GBase数据库助力湾区数字金融发展
[turn]: OSGi specification in simple terms
Do a small pressure test with JMeter tool
Generate filled text and pictures
[转]: OSGI规范 深入浅出
随机推荐
BUUCTF MISC
Solon Logging 插件的添加器级别控制和日志器的级别控制
Use the command character to close the keyboard command of the notebook
Shell Sort
Programmers' experience of delivering takeout
Unity card flipping effect
一个新的微型ORM开源框架
PR first time
Lua GBK and UTF8 turn to each other
Cocos2dx screen adaptation
[sum of two numbers] 169 sum of two numbers II - enter an ordered array
对象的序列化
[转]MySQL操作实战(三):表联结
Research on the value of background repeat of background tiling
[binary search] 69 Square root of X
Embedded database development programming (zero)
LeetCode之單詞搜索(回溯法求解)
[turn to] MySQL operation practice (I): Keywords & functions
The next key of win generates the timestamp file of the current day
64 horses, 8 tracks, how many times does it take to find the fastest 4 horses at least