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

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

代码如下:

 #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. Fragment+RadioButton实现点击切换页面效果

    首先我们需要在主布局文件中 放一个 容器,方便让fragment加入进去,我们创建了四个Fragment,并用RedioButton实现了导航栏 MainActivity.java package c ...

  2. iOS学习之界面通信

    一.属性传值 在SecondViewController.h里 #import <UIKit/UIKit.h> @interface SecondViewController : UIVi ...

  3. SharePoint 2010 RBS 安装和配置遇到的一个问题

    在按照微软官方的文档按照配置的时候遇到下面问题: <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event ...

  4. DSP28335矩阵键盘的检测

    #include "DSP2833x_Device.h"#include "DSP2833x_Examples.h"char temp;void gpio_in ...

  5. 套接字I/O模型之WSAEventSelect

    今天我又学习了一种新的套接字I/O模型------WSAEventSelect,他与WSAAsyncSelect一样也是一种异步事件通知模型,不同的是WSAAsyncSelect是与窗口句柄关联在一起 ...

  6. XAML中ContentControl,ItemsControl,DataTemplate之间的联系和区别

    接触XAML很久了,但一直没有深入学习.今天学习了如标题所示的内容,所以来和大家分享一下,或者准确的说是自我回顾一遍. 在XAML中,有两类我们常见的控件,分别是ContentControl和Item ...

  7. UITableView 应用及其总结

    Plain: Grouped: Cell的结构图: UITableViewCellStyleDefault:预设使用这种,若左侧ImageView没图的话,只有一行字(textLable.text). ...

  8. Linux 前台 和 后台进程 说明

    一. 有关进程的几种常用方法 1.1  & 符号 在命令后面加上一个 & 符号,表示该命令放在后台执行,如: [oracle@singledb ~]$ crontab -l 20 17 ...

  9. PE格式的理解(待补充)

    PE文件格式 一.基本结构 1.DOS头一般到节区头成为PE头部分,其下称为PE体.文件的内容一般可分为代码(.text).数据(.data).资源(.rsrc),分别保存. 2.PE头与各节区的尾部 ...

  10. javascript学习小记(一)

    大四了,课少了许多,突然之间就不知道学什么啦.整天在宿舍混着日子,很想学习就是感觉没有一点头绪,昨天看了电影激战.这种纠结的情绪让我都有点喘不上气啦!一点要找点事情干了,所以决定找个东西开始学习.那就 ...