首页 > 其他 > 详细

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

时间:2014-02-20 00:10:37      阅读:467      评论:0      收藏:0      [点我收藏+]

题目链接

 

题意 : 给你一个半径为n的圆,圆里边还有圆上都有很多整点,让你找出与圆外的任意一个整点距离等于1的点。

思路 :这个题可以用枚举,画个图就发现了,比如说先数第一象限的,往下往右找,还可以找规律,看到神代码就4行,我十分佩服数学学的特别好的人。。。。

大神博客地址

下边这个是枚举的代码,也很简单。

bubuko.com,布布扣
bubuko.com,布布扣
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL __int64
LL dis(LL x,LL y)
{
    return x*x+y*y;
}
int main()
{
    LL n;
    LL i,s;
    while(~scanf("%I64d",&n))
    {
        if(n==0)
        {
            cout<<"1"<<endl;
            continue;
        }
        LL sum = 0 ;
        s = n ;
        LL flag;
        for(i = 1 ; i <= n ; i++)
        {
            flag = 0;
            while(n*n < i*i+st*st)
            {
                sum++;
                st--;
                flag = 1 ;
            }
            if(flag == 0)
            {
                sum++;
            }
        }
        cout<<sum*4<<endl;
    }
    return 0;
}
View Code
bubuko.com,布布扣

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

原文:http://www.cnblogs.com/luyingfeng/p/3555859.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!