How to do Guess Num of Lunchtime Dec 2019?

Post much be at least 20 characters

Good Good bye 5 stars :stuck_out_tongue:

I didn’t get the full solution. So not sure. But I think that was because I was not paying attention to the thing that the output numbers must be in increasing order.
So what I did was this, M = AN + d so N can be written as P * d as N is divisible by d.
So equation is d = M/(1+pA), now find factors of M, see for which factors of M the value of p is integral, and then N = p*d

Again, not sure.

This is very easy to solve just get all factors of m in sqrt m time and these all factors are your value of d now you got d you have a and m then you can calculate all valid n

And enjoy such an easy ltime this time

We have M = A*N+d Writing N = x*d, we get M = d*(A*x+1) which means the chosen divisor d divides M.

Just check all divisors of M and see if it generates a valid choice of x*d

8 Likes

You sound like you’ve done all 5 questions

I have done nill as I am in train right now travelling to my university station but I saw each and everyone and passed sample cases and also I am typing all things from my phone only. And I guarantee that this LTIME was very easy then previous ones

1 Like

Last time was easier, but my stupid brain couldn’t think of easy APARTS problem :frowning:

Hope in tough competitions also I score very well on codeforces and become a LMaster there. My aim…

2 Likes

This time was very easy . First question 20 lines code second question 10 lines code. This time Challenge was also easy but Cook off was tough

1 Like

Good luck bro.

I was able to get O(m/a) solution i.e; linear but i got only 50 points. The idea is very easy as it is in the form of dividend=divisor*quotient+remainder. The maximum value of N i.e quotient will be m/a. From m/a to 1 check every value that satisfies the given condition.
My 50 points sol: CodeChef: Practical coding for everyone

re- write the equation as (m-d)/a=n , so from this we get two conditions (m-d)%a==0 and n%d==0 also 1<=d<m.
if we re-write equation as m=d*(ay+1) (putting n=yd) , it is confirmed that d is a divisor of m. so calculating all divisors of m and putting it in first two conditions solves the question.

solution in c++

#include <bits/stdc++.h>
#define ll long long int
#define endl ‘\n’
using namespace std;

int main() {
ll t;
for(cin>>t;t>0;t–)
{
ll a,n,d,m,c=0,i=2,j;
cin>>a>>m;
vectord1,arr;
d1.push_back(1);
for(;i<=sqrt(m);i++)
{
if(m%i==0)
{
d1.push_back(i);
d1.push_back(m/i);
}
}
for(j=0,i=0;j<d1.size();j++)
{
d=d1[j];
if((m-d)%a==0)
{
n=(m-d)/a;
if(n%d==0)
arr.push_back(n);
}
}
cout<<arr.size()<<endl;
sort(arr.begin(),arr.end());
for(i=0;i<arr.size();i++)
cout<<arr[i]<<" ";
cout<<endl;
}
return 0;
}