CF 50E. Square Equation Roots
思路:这题的关键就是重复根只可能是整数。
这样先求出所有的根的数目,在减去重复的根。
代码如下:
#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的更多相关文章
- CF Theatre Square
Theatre Square time limit per test 2 seconds memory limit per test 64 megabytes input standard input ...
- [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, ...
- cf-公式专场
A. Again Twenty Five! time limit per test 0.5 seconds memory limit per test 64 megabytes input stand ...
- codeforce 630N Forecast
N. Forecast time limit per test 0.5 seconds memory limit per test 64 megabytes input standard input ...
- Experimental Educational Round: VolBIT Formulas Blitz N
Description The Department of economic development of IT City created a model of city development ti ...
- Codeforces--630N--Forecast(方程求解)
N - Forecast Crawling in process... Crawling failed Time Limit:500MS Memory Limit:65536KB 64 ...
- UVA 1426 - Discrete Square Roots(数论)
UVA 1426 - Discrete Square Roots 题目链接 题意:给定X, N. R.要求r2≡x (mod n) (1 <= r < n)的全部解.R为一个已知解 思路: ...
- cf 460 E. Congruence Equation 数学题
cf 460 E. Congruence Equation 数学题 题意: 给出一个x 计算<=x的满足下列的条件正整数n的个数 \(p是素数,2 ≤ p ≤ 10^{6} + 3, 1 ≤ a ...
- Square roots
Loops are often used in programs that compute numerical results by starting with an approximate answ ...
随机推荐
- bzoj 3196/tyvj p1730 二逼平衡树
原题链接:http://www.tyvj.cn/p/1730 树套树... 如下: #include<cstdio> #include<cstdlib> #include< ...
- SQL Server中查询用户的对象权限和角色的方法
--SQL Server中查询用户的对象权限和角色的方法 -- 查询用户的object权限 exec sp_helprotect NULL, 'sa' -- 查询用户拥有的role exec sp_h ...
- 7.Knockout.Js(Mapping插件)
前言 Knockout设计成允许你使用任何JavaScript对象作为view model.必须view model的一些属性是observable的,你可以使用KO绑定他们到你的UI元素上,当这些o ...
- Charles移动端抓包工具使用
软件Charle 是一个HTTP代理服务器,HTTP监视器,反转代理服务器.它允许一个开发者查看所有连接互联网的HTTP通信.这些包括request, response现HTTP headers (包 ...
- Android实现网络访问
Android实现网络访问 开发工具:Andorid Studio 1.3 运行环境:Android 4.4 KitKat 工程内容 1) 熟练使用HttpURLConnection访问WebServ ...
- “我爱淘”第二冲刺阶段Scrum站立会议1
完成任务: 完成了webservice的配置与测试,实现了在客户端的搜索功能,并且可以实现图书的发布功能,就是将图书的信息添加到数据库中. 计划任务: 在客户端实现分类功能,通过学院的分类查看书籍. ...
- [转载]ubuntu下如何更改mysql数据存放路径
http://www.gaojinbo.com/ubuntu%E4%B8%8B%E5%A6%82%E4%BD%95%E6%9B%B4%E6%94%B9mysql%E6%95%B0%E6%8D%AE%E ...
- Liferay IDE 3.1 M1发布啦
很嗨森,以后就再也不用SDK和下载.ivy啦 新增功能主要有: 1.Liferay Workspace(用来存放Liferay Module项目) 2. Liferay Gradle Module P ...
- sourceInsight使用技巧,持续更新中~~~
作为测试人员,读各种平台的工程代码时,根本不想安装各种vs或者eclipse等,于是,就找了一款代码阅读工具. sourceInsight,下载地址为官网:http://www.sourceinsig ...
- SQL Server性能优化(1)使用SET函数
在一切开始之前,先看下微软的建议:在系统的整体性能优化里面, TSQL优化优先级并不是最高的. 本文包括四部分: SET STATISTICS TIME ON SET STATISTICS IO SE ...