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

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

代码如下:

 #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. Helloworld模块之内核makefile详解

    Hello World 模块以及对应的内核makefile详解 hello.c: #include <linux/module.h> //所有模块都需要的头文件 #include < ...

  2. ios中用drawRect方法绘图的时候设置颜色

    设置画笔颜色可以直接 [[UIColor grayColor] set];就可以设置颜色.

  3. Go实现线程池

    本文通过代码讲解如何实现一个线程池.代码(来自https://gobyexample.com/)及注释如下: package main import "fmt" import &q ...

  4. iOS中远程推送实现—在Apple的生产环境上测试Push Notifications功能

    1.在“Provisioning Profiles”中点击“Add”按钮. 2.在“What type of provisioning profile do you need?”页面中选择“Distr ...

  5. 41.使用Chipscope时如何防止reg_wire型信号被优化掉

    随着FPGA设计复杂程度越来越高,芯片内部逻辑分析功能显得越来越重要.硬件层次上的逻辑分析仪价格十分昂贵,而且操作比较复杂.目前,FPGA芯片的两大供应商都为自己的FPGA芯片提供了软件层面上的逻辑分 ...

  6. Could not resolve placeholder

    使用spring的<context:property-placeholder location="/WEB-INF/redis.properties"/>读取prope ...

  7. 【每日scrum】NO.1

    今天我们小组正式开始了冲刺,问题还是不少的,有必要记录下来来指导和改进后续的工作: 1.负责去找地图,却发现地图不能很好的适应我们的软件,略心塞>>> 2.本来计划把迪杰斯特拉算法看 ...

  8. mongodb修改器

    mongodb修改器 转载自:http://blog.csdn.net/mcpang/article/details/7752736 mongodb修改器(\(inc/\)set/\(unset/\) ...

  9. Careercup - Google面试题 - 5680330589601792

    2014-05-08 23:18 题目链接 原题: If you have data coming in rapid succession what is the best way of dealin ...

  10. 【转】PLSQL developer 连接不上64位Oracle 的解决方法

    PLSQL developer 连接不上64位Oracle 的解决方法 快乐无极 , 2012/06/13 10:10 , 开发文档 , 评论(6) , 阅读(140430) , Via 本站原创 大 ...