当前位置:网站首页>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;
}
}
}
边栏推荐
- To the distance we have been looking for -- film review of "flying house journey"
- Transport connection management of TCP
- Download and use of font icons
- Unity intelligent NPC production -- pre judgment walking (method 1)
- Under the national teacher qualification certificate in the first half of 2022
- Collapse of adjacent vertical outer margins
- 用 Jmeter 工具做个小型压力测试
- [binary search] 69 Square root of X
- 被舆论盯上的蔚来,何时再次“起高楼”?
- Merge sort
猜你喜欢

Fragment addition failed error lookup

C语言杂谈1

Applet Live + e - commerce, si vous voulez être un nouveau e - commerce de détail, utilisez - le!

Unity get component

stm32Cubemx(8):RTC和RTC唤醒中断

Embedded database development programming (V) -- DQL
![[interval problem] 435 Non overlapping interval](/img/a3/2911ee72635b93b6430c2efd05ec9a.jpg)
[interval problem] 435 Non overlapping interval

2022/7/2做题总结
![[轉]: OSGI規範 深入淺出](/img/54/d73a8d3e375dfe430c2eca39617b9c.png)
[轉]: OSGI規範 深入淺出
![[trans]: spécification osgi](/img/54/d73a8d3e375dfe430c2eca39617b9c.png)
[trans]: spécification osgi
随机推荐
[binary search] 69 Square root of X
Unity check whether the two objects have obstacles by ray
十年不用一次的JVM调用
Development error notes
Lua determines whether the current time is the time of the day
Unity writes timetables (without UI)
PMP candidates, please check the precautions for PMP examination in July
[binary search] 34 Find the first and last positions of elements in a sorted array
[转]MySQL操作实战(一):关键字 & 函数
Common database statements in unity
Reverse one-way linked list of interview questions
嵌入式数据库开发编程(六)——C API
[轉]: OSGI規範 深入淺出
cocos2dx_ Lua card flip
[sum of two numbers] 169 sum of two numbers II - enter an ordered array
TF-A中的工具介绍
Page countdown
What is the agile proportion of PMP Exam? Dispel doubts
Ue4/ue5 illusory engine, material chapter, texture, compression and memory compression and memory
django连接数据库报错,这是什么原因