-
Notifications
You must be signed in to change notification settings - Fork 0
/
112_D.cpp
65 lines (58 loc) · 933 Bytes
/
112_D.cpp
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
bool find(int n1,int t1,int t2)
{
if(n1>=t1 && n1<=t2)
return true;
int k = t1/n1;
while(true)
{
int m = n1*k;
if(m>t2)
return false;
if(m>=t1 && m<=t2)
return true;
k++;
}
return false;
}
int main()
{
int n;
cin>>n;
while(n--)
{
int xi,yi;
cin>>xi>>yi;
int sqrT = sqrt(xi);
int count = 0;
for(int i=1;i<=sqrT;i++)
{
if(xi%i!=0)
continue;
int n1 = i;
int n2 = xi/i;
int t1 = xi-yi;
int t2 = xi-1;
if(true)
{
bool found = find(n1,t1,t2);
cout<<n1<<" "<<t1<<" "<<t2<<" "<<found<<" "<<t1/n1<<endl;
if(!found)
count++;
}
if(n1!=n2)
{
bool found = find(n2,t1,t2);
cout<<n2<<" "<<t1<<" "<<t2<<" "<<found<<" "<<t2/n2<<endl;
if(!found)
//cout<<n2<<" "<<t1<<" "<<t2<<" "<<found<<" "<<t2/n2<<endl;
count++;
}
}
cout<<count<<endl;
}
return 0;
}