我的方式是用暴力的方法找到每一行每一列的边界点;

但是有大神直接用一个公式解决了:floor(n*sqrt(2))*4;

想了很久还是不理解,求各路大神指点!

#include<iostream>
#include<cmath>
#include<cstring>
using namespace std; int main()
{
long long n;
cin>>n;
if(n==){cout<<;return ;}
long long pre=,cur;
long long ans=;
for(long long i=;i<=n;i++)
{
cur=(long long)(sqrt(1.0*(n*n-i*i)));
ans++;
if(pre-cur>)
ans+=pre-cur-;
pre=cur;
}
ans--;
cout<<ans*;
}

codeforces 392A Blocked Points的更多相关文章

  1. Codeforces Round #230 (Div. 2) C Blocked Points

    题目链接 题意 : 给你一个半径为n的圆,圆里边还有圆上都有很多整点,让你找出与圆外的任意一个整点距离等于1的点. 思路 :这个题可以用枚举,画个图就发现了,比如说先数第一象限的,往下往右找,还可以找 ...

  2. codeforces 19D D. Points 树套树

    D. Points Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/19/problem/D De ...

  3. codeforces B.Fixed Points

    link:http://codeforces.com/contest/347/problem/B 很简单,最多只能交换一次,也就是说,最多会增加两个.可能会增加一个.也可能一个也不增加(此时都是fix ...

  4. codeforces 577E E. Points on Plane(构造+分块)

    题目链接: E. Points on Plane time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  5. codeforces B. Fixed Points 解题报告

    题目链接:http://codeforces.com/problemset/problem/347/B 题目意思:给出一个包含n个数的排列a,在排列a中最多只能作一次交换,使得ai = i 这样的匹配 ...

  6. codeforces 19 D. Points(线段树+set二分)

    题目链接:http://codeforces.com/contest/19/problem/D 题意:给出3种操作:1)添加点(x,y),2)删除点(x,y),3)查询离(x,y)最近的右上方的点. ...

  7. Codeforces C Match Points(二分贪心)

    题目描述: Match Points time limit per test 2 seconds memory limit per test 256 mega bytes input standard ...

  8. Codeforces 871C 872E Points, Lines and Ready-made Titles

    题 OvO http://codeforces.com/contest/871/problem/C ( Codeforces Round #440 (Div. 1, based on Technocu ...

  9. CodeForces 1000C Covered Points Count(区间线段覆盖问题,差分)

    https://codeforces.com/problemset/problem/1000/C 题意: 有n个线段,覆盖[li,ri],最后依次输出覆盖层数为1~n的点的个数. 思路: 区间线段覆盖 ...

随机推荐

  1. [Laravel] 获取执行的Sql

    获取数据库操作记录 $queries = DB::getQueryLog(); //取最后一条是 $lastSql = end($queries); 不过这样输出的,不是真正的sql,输出的是类似PD ...

  2. CSS实现半透明的方法

    IE8不支持以前{filter:alpha(opacity=50);}的私有属性, 转而支持更规范的私有属性-ms-filter: “progid:DXImageTransform.Microsoft ...

  3. h2database源码浅析:集群

    Clustering / High Availability This database supports a simple clustering / high availability mechan ...

  4. Cordova+angularjs+ionic+vs2015开发(三)

    欢迎加群学习:457351423 这里有4000多部学习视频,涵盖各种技术,有需要的欢迎进群学习! 一.基础设置 1.修改App名称和程序起始页 打开config.xml配置文件显示如下,在[通用]选 ...

  5. C语言对文件的相关命令

    fopen(文件名,使用文件的方式):打开数据文件 fclose(FILE *fp):关闭数据文件 feof(FILE *fp):是判断是否到fp的结尾 fputc(char ch,FILE *fp) ...

  6. 华为机试_字符串识别_Vector的使用;

    第一题:拼音转数字输入是一个只包含拼音的字符串,请输出对应的数字序列.转换关系如下:描述:      拼音        yi  er  san  si  wu  liu  qi  ba  jiu  ...

  7. c#解析Josn(解析多个子集,数据,可解析无限级json)

    首先引用 解析类库 using System; using System.Collections.Generic; using System.Linq; using System.Text; name ...

  8. S.O.L.I.D

    S.O.L.I.D.是一组面对面向对象设计的最佳实践的设计原则.术语来自Robert C.Martin的著作Agile Principles, Patterns, and Practices in C ...

  9. Linux之CentOS下vsftp安装及配置相关操作

    1.安装ftps——vsftpd: #yum install vsftpd 2.指定上传下载目录配置: 如:用户名:xxx,需指定目录:/xxx/xxx #useradd -d /xxx/xxx -s ...

  10. C#基础(六)——值类型与引用类型

    CLR支持两种类型:值类型和引用类型. 值类型包括C#的基本类型(用关键字int.char.float等来声明),结构(用struct关键字声明的类型),枚举(用enum关键字声明的类型):而引用类型 ...