Algorithm title: UVa 11461 Square Numbers (Simple mathematics)

Source: Internet
Author: User
Tags square root time limit

11461-square Numbers

Time limit:1.000 seconds

Http://uva.onlinejudge.org/index.php? OPTION=COM_ONLINEJUDGE&ITEMID=8&CATEGORY=467&PAGE=SHOW_PROBLEM&PROBLEM=24 56

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

Input

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

Output

For each line of the 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 Output for sample input

Water.

/*0.022s*/
  
#include <cstdio>
#include <cmath>
  
int main (void)
{
    int a, b;
    while (scanf ("%d%d", &a, &b), a)
        printf ("%d\n", (int) sqrt (b)-(int) ceil (sqrt (a)) + 1);
    return 0;
}

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.