Friday 3 February 2017

UVA 11461 - Square Numbers

Problem: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=24&problem=2456&mosmsg=Submission+received+with+ID+18720652

Code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,aa,bb;
    long long i;
    while(cin>>a>>b)
    {
        aa=sqrt(a);
        bb=sqrt(b);
        if(a==0&&b==0)
            break;
            if(aa*aa==a)
                aa--;

        cout<<bb-aa<<endl;
    }
    return 0;

}

No comments:

Post a Comment