博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVA 11461.Square Numbers
阅读量:4342 次
发布时间:2019-06-07

本文共 1063 字,大约阅读时间需要 3 分钟。

 

 

Time limit: 1.000 seconds 

A square number is an integer number whose square root is also an integer. For example 1, 4, 81 are some square numbers. Given two numbers a and b you will have to find out how many square numbers are there between a and b (inclusive).

Input

The input file contains at most 201 lines of inputs. Each line contains two integers a and b (0 < a ≤ b ≤ 100000). Input is terminated by a line containing two zeroes. This line should not be processed.

Output
For each line of input produce one line of output. This line contains an integer which denotes how many square numbers are there between a and b (inclusive).
Sample Input
1 4

1 10

0 0

Sample Output
2

3

题意就是a-b(包括a,b)的范围内有多少个平方数。

 

代码:

#include
#include
int main(){ int n,m,ans,cnt,i; while(~scanf("%d%d",&n,&m)){ if(n==0&&m==0)break; ans=0; for(i=n;i<=m;i++){ cnt=sqrt(i); if(cnt*cnt==i) ans++; } printf("%d\n",ans); } return 0;}

 

转载于:https://www.cnblogs.com/ZERO-/p/7113047.html

你可能感兴趣的文章
Windows之IOCP
查看>>
WebSocket & websockets
查看>>
openssl 升级
查看>>
ASP.NET MVC:通过 FileResult 向 浏览器 发送文件
查看>>
CVE-2010-2883Adobe Reader和Acrobat CoolType.dll栈缓冲区溢出漏洞分析
查看>>
使用正确的姿势跨域
查看>>
AccountManager教程
查看>>
Android学习笔记(十一)——从意图返回结果
查看>>
算法导论笔记(四)算法分析常用符号
查看>>
ultraedit激活
查看>>
总结(6)--- python基础知识点小结(细全)
查看>>
亿级曝光品牌视频的幕后设定
查看>>
ARPA
查看>>
JSP开发模式
查看>>
我的Android进阶之旅------&gt;Android嵌入图像InsetDrawable的使用方法
查看>>
Detours信息泄漏漏洞
查看>>
win32使用拖放文件
查看>>
Android 动态显示和隐藏软键盘
查看>>
raid5什么意思?怎样做raid5?raid5 几块硬盘?
查看>>
【转】how can i build fast
查看>>