GUESSNUM Editorial

I used the same approach given here , But even though getting TLE for Subtask 2
https://www.codechef.com/viewsolution/34707506
Can anyone say me where I’m missing out…

https://www.codechef.com/viewsolution/34708781
The Exact same code that of Editorialist with just change In variables is giving TLE…
What’s wrong here…? Compiler or the code.
Plz someone help me I’m unable to figure it out

TLE Solution : CodeChef: Practical coding for everyone
AC Solution : CodeChef: Practical coding for everyone
The only difference between them is each operator and operand have spaces between them .
Do the spaces between operators and operands really matter that much…??

Help me do not know where my code is failing

Here is my solution

#include<bits/stdc++.h>
using namespace std;
/*
do not voilate rules
*/
void fastio()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}

int main()
{
fastio();
long long int t;
cin>>t;
while(t–)
{
long long int a,m,n,d;

  cin>>a>>m;
  
  float tester;  
  
  if(a!=0)
  {
   tester=(float)m/a;
  }
  
  n=(long long int)tester;
  
  float diff;
  
  set<int>s;
  
  while(n>0)
  {
    diff=(float)(tester-n);
    d=diff*a;
    if(n<d)
    {
        break;
    }
    
    if(d!=0&&n%d==0)
    s.insert(n);
    
    n--;
  }
  
  cout<<s.size()<<endl;
  
 for(auto it:s)
 cout<<it<<" ";
  
  cout<<endl;
}

}

plz help me @codinginveins @nagasai74 @rishup_nitdgp

what’s wrong in my code… my output is same as of example output. please help guys.here is my code…

#include
#include
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int a,m,x,count=0;
cin>>a>>m;
x=m/a;
vectorv;
for(int i=x-a;i<=x;i++)
{
int check=m-(a*i);
if(check==0)
continue;
if(i%check==0)
{
v.push_back(i);
count++;
}
}
cout<<count<<’\n’;
for(int i=0;i<v.size();i++)
{
cout<<v[i]<<" ";
}
cout<<’\n’;
}
}

I didn’t understand your logic. Could you explain what is happening in your code?

#include <bits/stdc++.h>
using namespace std;
int main()
{
long long int t,a,m,i,flag,b[100003],j,p,q;
scanf("%lld",&t);
for(i=1;i<=t;++i)
{
scanf("%lld%lld",&a,&m);
flag=0;
for(j=1;(j*j)<=m;++j)
{
if((m%j)==0)
{
p=j;
q=m/j;
if(j==1)
{
if((q%a)==1)
{
flag+=1;
b[flag]=(q/a)*p;
}
}
else
{
if(p==q)
{
if((q%a)==1)
{
flag+=1;
b[flag]=(q/a)*p;
}
}
else
{
if((q%a)==1)
{
flag+=1;
b[flag]=(q/a)*p;
}
if((p%a)==1)
{
flag+=1;
b[flag]=(p/a)*q;
}
}
}
}
}
if(flag==0)
{
printf(“0\n”);
}
else
{
sort(b+1,b+flag+1);
printf("%lld\n",flag);
for(j=1;j<=flag;++j)
{
printf("%lld “,b[j]);
}
}
printf(”\n");
}
}
Can anyone tell why is this code getting “WA”? I