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

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

代码如下:

 #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. 说明一下JNI 与AIDL

    代码在评论中. JNI: 为什么需要JNI: 因为android是由[JAVA & C/C++]组成.Java运行在Dalvik虚拟机中. 没有办法直接访问底层硬件.底层HW相关目前技术一般都 ...

  2. Object C学习初步

    最近乘着项目不太紧张的时候,赶紧给自己冲了一下电.其实我自己最熟悉的平台应该是.net,所以当初上手windows phone的话是很快,我记得当初是一边跟着项目进展,一边自己开始学习前台的XAML语 ...

  3. Go实现线程池

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

  4. python中有趣的函数

    filter(function, sequence):对sequence中的item依次执行function(item),将执行结果为True的item组成一个List/String/Tuple(取决 ...

  5. Quartus13.0破解方法

    一定要按照步骤顺序才能破解,这里很关键 1.下载和打开Quartus II破解器,选择“应用”,选择“是”,找到bin(64位系统是bin64)目录下的sys_cpt.dll,“打开” 2.然后将li ...

  6. 制作OpenStack用的RHEL7系统镜像

    制作OpenStack使用的RHEL7系统镜像,并进行相关设置,安装XRDP以进行远程访问. 1.在KVM中安装RHEL7.2客户机: 2.设置网卡为dhcp并onboot=yes,使得虚拟机能自动获 ...

  7. C++中数组求偏移量计算公式

    已知数组:type A[10][5]A[0][0] --A[8][4]面试常考:数组定义A[0....x][0...y]已知A[m][n] --求A[k][l]的地址:    &A[m][n] ...

  8. asdoc 档案

    1.asdoc air项目会出现无法找到NativeApplication等错误 解决办法:add args   -load-config ....../frameworks/air-config.x ...

  9. org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

    org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actua ...

  10. 如何实现SAP的RFC函数调用(原创)

    连接sap系统需要通过sap javaconnect来连接,对于sapjco.jar系列文件有32位与64位之分[32位用的JAR版本是 2.1.10 (2011-05-10) ,64位用的JAR版本 ...