zoukankan      html  css  js  c++  java
  • Codeforces Round #230 (Div. 1) 解题报告

    第一题太坑了。所以只做出来一道题TAT

    Problem A Blocked Points

    题意:求直径为n的圆边界上有多少个点。

    思路:根据对称性只需求出四分之一圆再乘四就可以了。枚举x轴坐标。题目本身一点都不难有木有!!但是我被坑了有木有!!!第五组测试数据0有木有!!!我一直到还剩二十分钟才发现的。so sad

    代码如下:

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstdlib>
     4 #include <cmath>
     5 #include <cstring>
     6 #include <algorithm>
     7 #include <queue>
     8 #include <stack>
     9 #include <vector>
    10 #include <set>
    11 #include <map>
    12 #define MP(a, b) make_pair(a, b)
    13 #define PB(a) push_back(a)
    14 
    15 using namespace std;
    16 
    17 typedef long long ll;
    18 typedef pair<int ,int> pii;
    19 typedef pair<unsigned int, unsigned int> puu;
    20 typedef pair<int ,double> pid;
    21 typedef pair<ll, int> pli;
    22 typedef pair<int, ll> pil;
    23 
    24 const int INF = 0x3f3f3f3f;
    25 const double eps = 1e-6;
    26 
    27 int main()
    28 {
    29 //    freopen("in.txt", "r", stdin);
    30 
    31     ll n, sum;
    32     while(cin >> n){
    33         if(!n) {
    34             cout << 1 << endl;
    35             continue;
    36         }
    37         ll loc = n;
    38         sum = 1;
    39         for(int i=1; i<n; i++){
    40             ll x = n*n - (ll)i*i;
    41             double y = sqrt(x);
    42             sum += (loc - (ll)y);
    43             if((loc - (ll)y)==0) sum++;
    44             loc = (ll)y;
    45          }
    46          sum += (loc-1);
    47         cout << 4*sum << endl;
    48     }
    49     return 0;
    50 }
    View Code
    奔跑吧!少年!趁着你还年轻
  • 相关阅读:
    快速开发一个自己的微信小程序
    ES6系列汇总
    数组、Set对象的互相转换
    CORS 跨域
    模板引擎之hogan.js
    Flex 布局语法教程
    ES6 Javascript 实用开发技巧
    几种知名开源富文本编辑器对比
    python 字符串的一些操作
    python os模块一些常用操作
  • 原文地址:https://www.cnblogs.com/shu-xiaohao/p/3555117.html
Copyright © 2011-2022 走看看