in question GUESSNUM

what is role of sqrt(m) in the soln? why to optimise i am going till sqrt(m)??

and what is wrong with my approach … i tried several times but again it is showing tle securing only 50 pts ? please help me

my solution to the code : #include<bits/stdc++.h>

using namespace std;

#define lli long long int

int main()

{ios_base::sync_with_stdio(false);

cin.tie(NULL);

lli t,i,a,x,m,c,y,ma,z,vr;

cin>>t;

while(t–)

{cin>>a>>m;

vectorv;

c=0;

vr=(m/(a+1));

y=(m/a)*a;

if(y==m)

{y-=a;}

ma=y/a;

z=ma;

for(i=y;i>=0;i-=a)

{x=m-i;

if(x>vr)

{break;

}

if(ma%x==0)

{c+=1;

v.push_back(i/a);

}

ma-=1;

}

cout<<c<<"\n";

if(v.size()==0)

{cout<<"\n";

}

else{

sort(v.begin(),v.end());

for(auto itr=v.begin();itr!=v.end();++itr)

{cout<<*itr<<" “;

}

cout<<”\n";

}

}

return 0;

}

the link is :codechef.com/viewsolution/28556059

what i am doing is : i am going to all the multiples of a(i in code) till m and my d (x in code) becomes m-i and if my d becomes greater than m/(a+1) then i break the loop? so for 1st test case : a=3 and m=35 it is running only 3 times ? so what is wrong with my approach please help me out to figure out this problem