UVa 11461 - Square Numbers【数学,暴力】
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2456
题意
输入两个整数a和b,输出从a到b(包含a和b)的平方数的个数。直到输入0 0时程序结束
分析:
如果一个数n是平方数,(double)sqrt(n)-(int)sqrt(n)<1e-6。
下面给出AC代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m,i;
while(scanf("%d%d",&n,&m)!=EOF)
{
int count=;
if(n==&&m==)break;
for(i=(int)(sqrt(n-0.1))+;i*i<=m;i++)
{
count++;
}
printf("%d\n",count);
}
return ;
}
UVa 11461 - Square Numbers【数学,暴力】的更多相关文章
- UVA 11461 - Square Numbers 数学水题
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- UVA 11461 - Square Numbers(水题)
题目链接 #include <cstdio> #include <cstring> #include <string> #include <cmath> ...
- UVA 11461 - Square Numbers
题目:统计区间中的平方数个数. 分析: ... #include <stdio.h> #include <string.h> ]; int main() { int i, a, ...
- POJ2402/UVA 12050 Palindrome Numbers 数学思维
A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example,the ...
- UVA 12898 And Or 数学暴力
And Or Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.actio ...
- UVa 10006 - Carmichael Numbers
UVa 10006 - Carmichael Numbers An important topic nowadays in computer science is cryptography. Some ...
- UVA - 13022 Sheldon Numbers(位运算)
UVA - 13022 Sheldon Numbers 二进制形式满足ABA,ABAB数的个数(A为一定长度的1,B为一定长度的0). 其实就是寻找在二进制中满足所有的1串具有相同的长度,所有的0串也 ...
- Uva - 12050 Palindrome Numbers【数论】
题目链接:uva 12050 - Palindrome Numbers 题意:求第n个回文串 思路:首先可以知道的是长度为k的回文串个数有9*10^(k-1),那么依次计算,得出n是长度为多少的串,然 ...
- UVA 11542 - Square(高斯消元)
UVA 11542 - Square 题目链接 题意:给定一些数字.保证这些数字质因子不会超过500,求这些数字中选出几个,乘积为全然平方数,问有几种选法 思路:对每一个数字分解成质因子后.发现假设要 ...
随机推荐
- iOS 工程默认只允许竖屏,在单独界面进行横竖转换,屏幕旋转
只含有 .关于横竖屏的代码 #import "InspectionReportViewController.h" #define SCREEN_WIDTH ([UIScreen m ...
- linux下PHP后台配置极光推送问题
一.composer.json配置注意空格 按照极光推送官网所述,在composer.json下写入: "require": { "jpush/jpush": ...
- SQL基本查询_子查询(实验四)
SQL基本查询_子查询(实验四) 1.查询所有员工中薪水低于"孙军"的员工姓名和薪水: 2.查询与部门编号为"01"的岗位相同的员工姓名.岗位.薪水及部门号: ...
- Equilibrium point
Given an array A your task is to tell at which position the equilibrium first occurs in the array. E ...
- bzoj 3331: [BeiJing2013]压力
Description 如今,路由器和交换机构建起了互联网的骨架.处在互联网的骨干位置的 核心路由器典型的要处理100Gbit/s的网络流量.他们每天都生活在巨大的压力 之下. 小强建立了一个模型.这 ...
- 在海航云中部署 keepalived
**本文属自我学习,不适合转载** 1. 准备工作 1.1 网络方面的准备工作 1.1.1 创建安全组 注意这里要添加 vrrp 协议支持,否则 keepalived 将无法正常工作. 1.1.2 创 ...
- & 与 kill -3
mysqld_safe --defaults-file=/app/3307/my.cnf 2>&1 1>/dev/null & 将mysqld服务进程放入后台后, 因为忘记 ...
- Linux - Shell常用指令
一.文件.目录操作命令 1.ls命令:显示文件和目录的信息 ls 以默认方式显示当前目录文件列表 ls -a 显示所有文件包括隐藏文件 ls -l 显示文件属性,包括大小,日期,符号连接,是否可读写及 ...
- angularjs 字段排序 多字段排序
我们用angularjs {{}},ng-model循环绑定数组或对象的内容的时候,有时候会用到排序,有时候可能会有多个字段排序 具体要用到过滤 数据的展现,可以通过ng-repeat实现.当网页解析 ...
- Python装饰器的解包装(unwrap)
在Python 3.4 中,新增一个方法unwrap,用于将被装饰的函数,逐层进行解包装. inspect.unwrap(func, *, stop=None) unwrap方法接受两个参数:func ...