思路:这题的关键就是重复根只可能是整数。

这样先求出所有的根的数目,在减去重复的根。

代码如下:

 #include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define ll long long
using namespace std;
bool f[];
int main(){
ll n,m;
scanf("%I64d%I64d",&n,&m);
ll ans=;
memset(f,,sizeof(f));
for(ll b=;b<=n;b++){
ans+=min(*m,b*b*);
ll b2=b*b;
for(ll c=b-;c>=;c--){
if(b2-c*c>m) break;
if(f[b-c]) ans--;
else f[b-c]=;
if(f[b+c]) ans--;
else f[b+c]=;
}
}
printf("%I64d\n",ans);
return ;
}

CF 50E. Square Equation Roots的更多相关文章

  1. CF Theatre Square

    Theatre Square time limit per test 2 seconds memory limit per test 64 megabytes input standard input ...

  2. [CF 612E]Square Root of Permutation

    A permutation of length n is an array containing each integer from 1 to n exactly once. For example, ...

  3. cf-公式专场

    A. Again Twenty Five! time limit per test 0.5 seconds memory limit per test 64 megabytes input stand ...

  4. codeforce 630N Forecast

    N. Forecast time limit per test 0.5 seconds memory limit per test 64 megabytes input standard input ...

  5. Experimental Educational Round: VolBIT Formulas Blitz N

    Description The Department of economic development of IT City created a model of city development ti ...

  6. Codeforces--630N--Forecast(方程求解)

    N - Forecast Crawling in process... Crawling failed Time Limit:500MS     Memory Limit:65536KB     64 ...

  7. UVA 1426 - Discrete Square Roots(数论)

    UVA 1426 - Discrete Square Roots 题目链接 题意:给定X, N. R.要求r2≡x (mod n) (1 <= r < n)的全部解.R为一个已知解 思路: ...

  8. cf 460 E. Congruence Equation 数学题

    cf 460 E. Congruence Equation 数学题 题意: 给出一个x 计算<=x的满足下列的条件正整数n的个数 \(p是素数,2 ≤ p ≤ 10^{6} + 3, 1 ≤ a ...

  9. Square roots

    Loops are often used in programs that compute numerical results by starting with an approximate answ ...

随机推荐

  1. 部署git server

    http://gogs.io/docs/installation/install_from_binary.htmlwget http://gogs.dn.qbox.me/gogs_v0.6.5_lin ...

  2. php xml转为xml或者json

    <?php class XmlToArray { private $xml; private $contentAsName="content" ; private $attr ...

  3. 检测到有潜在危险的 Request.Form 值。 说明: ASP.NET 在请求中检测到包含潜在危险的数据

    在请求方法的顶部添加        [ValidateInput(false)]就OK了 从客户端(Content=" sdfdddd ...")中检测到有潜在危险的 Reques ...

  4. C#取枚举描述

    一直都觉得枚举是个很不错的东西,可以给我们带来很多方便,而且也增加代码的可读性. 我在之前已经介绍过枚举的简要应用了,再次再来写下怎么获取枚举的描述. 源码如下: 首先,我们定义个含有描述的枚举类型 ...

  5. 新手学Android

    Eclipse平台下的新手Android学习记录. 1.打开一个本地的项目 在Project Explorer右键->Import->Existing Projects into Work ...

  6. How to compile and install NCAR Command Language on IBM PowerPC 64 --- NCL编译安装步骤

    作者:Sinsonglew 出处:http://www.cnblogs.com/sinsonglew 欢迎转载,也请保留这段声明.thanks :) 注记:NCL官方依赖安装包全集列表.官方源码编译指 ...

  7. 微软职位内部推荐-Software Engineer II-SDP

    微软近期Open的职位: Position: SDE II The R&D of Shared Data Platform at Application and Services Group ...

  8. Eigen库实现简单的旋转、平移操作

    本来课程要求用GUI界面来实现Eigen的旋转.平移操作的,但是接触GUI编程时间太短,虽然要求很简单,但是做了几天还是没有完成.就把命令行下面的简单的贴一下吧. main.cpp #include ...

  9. Careercup - Google面试题 - 4699414551592960

    2014-05-06 13:34 题目链接 原题: we have a random list of people. each person knows his own height and the ...

  10. android 开发对gif解码(适配android 4.2、4.3、4.4版本)

    android 开发对gif解码(适配android 4.2.4.3.4.4版本) 使用方法: public class ImageInputActivity extends Activity imp ...