CF 392 Blocked Points

c. Blocked Points
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if:

  • the Euclidean distance between A and B is one unit and neither A nor B is blocked;
  • or there is some integral point C, such that A is 4-connected with C, and C is 4-connected with B.

Let's assume that the plane doesn't contain blocked points. Consider all the integral points of the plane whose Euclidean distance from the origin is no more than n, we'll name these points special. Chubby Yang wants to get the following property: no special point is 4-connected to some non-special point. To get the property she can pick some integral points of the plane and make them blocked. What is the minimum number of points she needs to pick?

Input

The first line contains an integer n (0 ≤ n ≤ 4·107).

Output

Print a single integer — the minimum number of points that should be blocked.


#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<map>
#include<stack>
#include<math.h>
using namespace std;

int main()
{
  //  freopen("in.txt","r",stdin);
   int n;
  while(~scanf("%d",&n))
  {
   int se=-1;
   int ans=0;
   long long N=1ll*n*n;//注意int范围!!
   for(int i=1;i<=n;i++)
   {
      int tp=sqrt(N-1ll*i*i);
      if(se==-1) se=tp;
      else
      {
          if(se==tp) ans++;
          else ans+= se-tp;
          se=tp;
      }
   }
   ans=(++ans)*4;
   if(n==0) ans=1;
   printf("%d\n",ans);
  }


    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Python中使用Selenium时,如果遇到了"blocked"错误,这通常指的是Selenium驱动试图访问某些网站资源时被网站的安全策略所阻拦。这可能是由于多种原因造成的,以下是一些常见的解决方案和预防措施: 1. 确保Selenium使用的浏览器驱动是最新的。网站的安全策略和防护措施经常更新,老版本的浏览器驱动可能不被支持或被网站安全机制识别为不合法的客户端。 2. 更新浏览器到支持的最新版本。一些网站可能不支持较旧版本的浏览器,确保浏览器是最新版本能够减少被网站安全机制阻拦的可能性。 3. 使用无头浏览器模式。无头模式是一种浏览器运行时的模式,它没有图形用户界面,所有网页的渲染和脚本的执行都在后台进行。这样可以减少被网站检测到是自动化工具的可能性。 4. 配置适当的用户代理(User-Agent)。有时候网站会基于User-Agent来区分访问请求是来自于常规浏览器还是自动化工具。可以尝试修改Selenium浏览器驱动的User-Agent设置,使其看起来更像常规的浏览器访问。 5. 检查是否有网络层面的限制。有时候防火墙、代理服务器或其他网络设备可能阻止Selenium访问目标网站,确保相关的网络设置不会误拦截Selenium的请求。 6. 如果是由于网站反爬虫机制导致的问题,可以考虑使用一些Selenium扩展插件,比如Selenium WebDriver配合第三方服务(如BrowserMob Proxy)来处理JavaScript渲染的页面。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值