-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathD.cpp
47 lines (45 loc) · 1.06 KB
/
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
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0)
int main()
{
fastio;
long long t,n,x,i,j,k,cnt,dist,it;
cin>>t;
while(t--)
{
it=0;
cin>>n>>x;
cnt=0;
for(i=1;i<=x/3,3*i*i<=n;i++)
{
for(j=i;;j++)
{
if(i+2*j>x || 2*i*j+j*j>n){
break;
}
for(k=j;;k++)
{
it++;
if(i+j+k>x || i*j+j*k+k*i>n)
break;
//cout<<i<<" "<<j<<" "<<k<<"\n";
dist=1;
if(j!=i)
dist++;
if(k!=i && k!=j)
dist++;
if(dist==1)
cnt++;
else if(dist==2)
cnt+=3;
else
cnt+=6;
}
}
}
//cout<<it<<"\n";
cout<<cnt<<"\n";
}
return 0;
}