-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.java
More file actions
51 lines (48 loc) · 1.35 KB
/
.java
File metadata and controls
51 lines (48 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.*;
public class insane
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int test = sc.nextInt();
while(test-->0)
{
int k = sc.nextInt();
int l1 = sc.nextInt();
int r1 = sc.nextInt();
int l2 = sc.nextInt();
int r2 = sc.nextInt();
int ans = 0;
int max = r2/l1; //isse chote hi hone hain sab ab
int l = k;
while(l<max)
{
l*=k;
}
l/=k;
//itna l ja sakta hai.
for(int i = l1 ; i <= r1 ; i++ )
{
for(int j = l2 ; j <= r2 ; j++)
{
if (i==j)
{
ans++;
}
else if(j%i==0) //valid hai
{
int value = j/i;
// System.out.println(i+" "+j+" "+value);
if(value <= l && value % k == 0)
{
// System.out.println(i+" "+j+"= "+value);
ans++;
}
}
}
}
System.out.println(ans);
}
sc.close();
}
}