codeforces 859B B. Lazy Security Guard
来源:互联网 发布:河南金汇鑫软件 编辑:程序博客网 时间:2024/06/07 23:34
Your security guard friend recently got a new job at a new security company. The company requires him to patrol an area of the city encompassing exactly N city blocks, but they let him choose which blocks. That is, your friend must walk the perimeter of a region whose area is exactly N blocks. Your friend is quite lazy and would like your help to find the shortest possible route that meets the requirements. The city is laid out in a square grid pattern, and is large enough that for the sake of the problem it can be considered infinite.
Input will consist of a single integer N (1 ≤ N ≤ 106), the number of city blocks that must be enclosed by the route.
Print the minimum perimeter that can be achieved.
4
8
11
14
22
20
Here are some possible shapes for the examples:
题目大意(来自百度翻译。。。。。。):你的保安的朋友最近买了一个新的工作在一个新的安全公司。该公司要求他在城市的一个区域巡逻,包括N个街区,但他们让他选择哪些街区。那就是,你的朋友要走一个区域的周边地区正是N块。你的朋友很懒,希望你的帮助能找到符合要求的最短路线。这座城市的布局为正方形网格,规模很大,为了解决这个问题,它可以被认为是无限的。
其实看图就能明白,它是要求几个小正方形拼起来以后周长最小是多少
#include<bits/stdc++.h>using namespace std;int main(){int n;while(cin>>n){cout<<2*(ceil(2*sqrt(n)))<<endl;}}
- codeforces 859B B. Lazy Security Guard
- Codeforces 859B Lazy Security Guard
- Codeforces 859B Lazy Security Guard
- Codeforces 605B Lazy Student
- 605B. Lazy Student(codeforces Round 335)
- [CodeForces 605B]Lazy Student[贪心][构造]
- CodeForces 605 B.Lazy Student(构造)
- codeforces 859B
- codeforces B
- codeforces B
- codeforces B
- codeforces B
- CodeForces 841B (B) 博弈
- CodeForces 626B CodeForces 626B【暴力】
- codeforces 134B
- codeforces#98 b
- codeforces 105 div2 B
- Codeforces 166B - Polygons
- r-cnn faster-rcnn 升级之路
- MySQL、Oracle、SQL Server各数据库服务的端口号?
- hdu 1260 Tickets
- Web开发介绍
- git提交后出现nano界面,解决方法
- codeforces 859B B. Lazy Security Guard
- 网络判断工具类
- 记录springmvc静态资源访问遇到的问题
- Hibernate如何让数据库自动创建时间(时间戳)
- iOS 11 将于9月19日正式发布,一文带你了解它的那些特性
- Spring(5.1、基于xml的事物)
- 题目199-无线网络覆盖
- SpringBoot学习-(三)SpringBoot开发Web
- 成都的互联网大厂,你知道几个?