0

Input

The first line contains the number of test cases t (1 ≤ t ≤ 5). Then t test cases follow, each test case consists of a line containing two integers n and k (0 ≤ n ≤ 100000, n < k ≤ 1018).
Output

For each test case output one line containing the required number.
Example

Input:
2
1 5
2 5

Output:
2
3

Explanation:

In the first test case, the only sought pairs are (2,2) and (3,3). In the second one, they are (3,3), (3,4) and (4,3).
This is my problem to solve.My code is....

#include<iostream>
#include<conio.h>

using namespace std;
int main()
{
int i,j,test,n,k,p,s,r,q,y,c;
cin>>test;
for(c=0;c<test;c++){
int a=0;
cin>>n>>k;
y=n;
for(i=n+1;i<=k-1;i++)
for(j=n+1;j<=k-1;j++)
{
p=i*j-y;
q=i-y;
r=j-y;
s=q*r;
if(p%s==0)
{
p=0;
q=0;
r=0;
s=0;
a++;
}
else
{
p=0;
q=0;
r=0;
s=0;
}
}
cout<<a;}
getch();
return 0;
}

The output for n=1 and k=8 is 2 not correct(2).
Whats wrong?

Edited by Onlineshade: n/a

4
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by Narue
-1

You didn't explain what you're supposed to do to get the output.

Given n and k, find the number of pairs of integers (a, b) such that n < a < k, n < b < k and ab-n is divisible by (a-n)(b-n).

0

On a side note, code tags are pointless if your code has no formatting. Please indent your code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.