zoukankan      html  css  js  c++  java
  • UVA 11461

    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

     1 #include <iostream>
     2 #include <cmath>
     3 #include <stdio.h>
     4 using namespace std;
     5 
     6 int main()
     7 {   int a,b,n;
     8     float m;
     9     while(~scanf("%d%d",&a,&b))
    10 {    n=0;
    11      if(a>0&&a<=b){
    12     for(int i=a;i<=b;i++)
    13     {  m=sqrt(i);
    14         if(m-(int)m==0)
    15         n+=1;
    16     } printf("%d
    ",n);
    17 }
    18 }
    19     return 0;
    20 }
  • 相关阅读:
    day9文件处理
    day8字符编码
    js小数乘法精确率问题
    webstorm上传vue代码至git
    vue项目关闭eslint检查
    MongoDB相关操作
    Redis持久化存储
    Redis 数据类型
    linux常用命令
    初识NoSQL
  • 原文地址:https://www.cnblogs.com/z-712/p/7323601.html
Copyright © 2011-2022 走看看