码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces Round #561 (Div. 2)

时间:2019-05-20 19:23:23      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:and   round   cup   个数   条件   bsp   target   contest   ORC   

C. A Tale of Two Lands

题意:

  给出 n 个数,问有多少点对(x,y)满足 |x-y| ≤ |x|,|y| ≤ |x+y|;

  (x,y) 和 (y,x) 表示一种答案;

题解:

  数形结合;

  对于某数 x 查找满足条件 y 有多少个;

  ①x ≥ 0

    y ∈ [x/2 , 2x] ∪ [ -2x , -x/2];

  ②x < 0

    y ∈ [2x , -x/2] ∪ [-x/2 , -2x];

  特别注意临界值 x/2 处;

AC代码:

 

Codeforces Round #561 (Div. 2)

标签:and   round   cup   个数   条件   bsp   target   contest   ORC   

原文地址:https://www.cnblogs.com/violet-acmer/p/10895792.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!