当前位置:网站首页>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;
}
}
}
边栏推荐
- PR first time
- When will Wei Lai, who has been watched by public opinion, start to "build high-rise buildings" again?
- Binary search basis
- Count sort
- 嵌入式数据库开发编程(六)——C API
- Django reports an error when connecting to the database. What is the reason
- Magnifying glass effect
- 一个新的微型ORM开源框架
- 2022/7/2做题总结
- Under the national teacher qualification certificate in the first half of 2022
猜你喜欢
Fragment addition failed error lookup
JVM call not used once in ten years
Unity find the coordinates of a point on the circle
[trans]: spécification osgi
Merge sort
Do a small pressure test with JMeter tool
Ue4/ue5 illusory engine, material part (III), material optimization at different distances
Download and use of font icons
[merge array] 88 merge two ordered arrays
Embedded database development programming (zero)
随机推荐
Pointnet++的改进
[to be continued] [UE4 notes] L1 create and configure items
UE4/UE5 虚幻引擎,材质篇,纹理,Compression and Memory压缩和内存
When will Wei Lai, who has been watched by public opinion, start to "build high-rise buildings" again?
发现一个很好的 Solon 框架试手的教学视频(Solon,轻量级应用开发框架)
Solon Logging 插件的添加器级别控制和日志器的级别控制
Lua determines whether the current time is the time of the day
Generate filled text and pictures
被舆论盯上的蔚来,何时再次“起高楼”?
Unity3d learning notes
[LeetCode] 整数反转【7】
Download xftp7 and xshell7 (official website)
Applet Live + e - commerce, si vous voulez être un nouveau e - commerce de détail, utilisez - le!
Leetcode word search (backtracking method)
Solon Auth 认证框架使用演示(更简单的认证框架)
cocos_ Lua listview loads too much data
十年不用一次的JVM调用
A complete attack chain
UE4/UE5 虚幻引擎,材质篇(三),不同距离的材质优化
Chinese notes of unit particle system particle effect