What sort of Mathematics codechef is providing?

I am bit disappointed by some of the question of the long challenges.
To the problem (https://www.codechef.com/APRIL19B/problems/SJ1)
Its just a formula based question. If someone knew the formula even newbie(like me) can easily do it, but if you don’t even the good coder(may be I am wrong here) can’t do it. I wanted the view of others. How it is justified to settle such problems or whether I am wrong ?


I too hate pure mathematics based ques
especially this long i.e MAY19 has too many mathematics based ques but maths is unfortunately an inseparable part of programming
I guess a contest shld hav mixture of probs based on maths, algo, logic
but again creating such probs is difficult as compared to creating formula based probs


I don’t hate maths but such type of question are not algorithm based .

There was just a formula? I had to use DFS to solve it.


1 Like

Obvio we need dfs to get nodes on path to the leaf
he is talking abt how the prob is reduced to gcd(x1,x2,…,b)

Was it difficult to implement dfs? My point is after all it was a formula based on gcd.



If you observe closely, you’ll come to know that it is not a formula based problem…
That formula you’re talking about, you’ll never find it on internet/any book. You have to derive it. And thats where these 2-skills come handy:-

1)Observing patterns.
2)More observation.

You can see my unofficial editorial on SJ1 and you’ll realize its all about observation+patterns :slight_smile:
Link : -Unofficial Editorial of SJ1


Obvio we need dfs to get nodes on path to the leaf he is talking abt how the prob is reduced to gcd(x1,x2,…,b)

So what if it reduces to that? Will a 2 star guy knowing basic math will be able to solve it? Nopes, because usually they dont know DFS.

Was it difficult to implement dfs? My point is after all it was a formula based on gcd.

Div2 stats appeal likewise to me. Because if the math is very simple for all of you then I dont see a reason for the problem to have < 1k submissions anyway.

And clarifying -

I will not call https://www.codechef.com/APRIL19B/problems/SJ1 as “pure formula based” because it needed DFS. If its trivial to you then good enough, but you cant discard DFS completely and say its 100% formula based.

I will call questions like https://www.codechef.com/ACMIND17/problems/COMPEXP and https://www.codechef.com/FEB19B/problems/GUESSRT as pure formula/math based.


Which formula, I didn’t know any formula existed before reading this post. I solved it by plain logic and little mathematical manipulation. Also I am not a very great coder so your point is invalidated. My 2-3 friends solved as well without knowing any formula

1 Like

CP has/is always about mathematics. No wonder we see a great correlation between IMO maths champions and red coders. A very well acclaimed problem would be having some creative observation behind it and most likely it will be related to mathematics. So, we cannot just eradicate mathematics out of CP. That would lead us to restrict the required knowledge of mathematics for CP. Since, any experienced CP coder can tell you branch of mathematics required for CP (number theory, game theory, reasoning, graph theory to name a few) which justifies this problem to be a reasonable one.

1 Like

I like this question too much because it just waste my 4 days during contest just to realize the formula…

1 Like

I vehemently disagree with you. This was a very good question. I’m also not sure what ‘formula’ you are talking about.

Personally, I love Mathematics. This was a good question.

There have been instances of problems in the past which are actually trivial if you know some vague fact, but this is not one of them. This was a straightforward GCD question with a twist, and can be solved entirely by thinking.

CodeChef has been working hard to improve their problem quality and their forum quality of late. The quality of problems has improved a bit after they introduced Divisions. Although there have been instances when problems have not been good, let us not unnecessarily discourage them.

I loved this question and look forward to seeing many more Mathematical questions on CodeChef!


here it was even in on going contest.

Agreed but you were forced to use dfs since the question itself stated about the tree.

ans= b−gcd(a1,a2,a3,…,an,b).

Try to understand that it was during the contest on internet. It did not exist before,anywhere.
. See, if you wanna cheat, then one can find the formula/answers on internet as well by directly asking people thats why short contests are considered as real competitive programming.

1 Like

Your argument completely misses the essence of my argument and sticks on only one irrelevant point that “DFS was obvious”. I answered that already in my argument earlier.

1 Like

Unrelated topic:- Will we ever get chef vijju’s editorials again? Really missing them :frowning: :frowning:

1 Like

Perhaps sometime in summer. Really can’t say at the moment. Every time I sign up to write editorials…its a funny cycle.

  1. I have a look at the problems.
  2. I say “DUCK!” and feel I couldn’t do editorials in time. They all seem so tough!
  3. Realize P1 to P3 were ez as heck - its just me overreacting XD
  4. Write for all problems except last 2.
  5. Bang my head, curse myself for signing up to write editorials and repeatedly send clarification mails to setter/tester hoping some explanation will bail me out. A bit background into this, at times the setter explanation is…very much “sparse”. I once got a expln which only told time complexity and did not tell what he did in solution at all LOL.
  6. Somehow by God’s grace something strikes my brain and I write the editorial.

Point 6 happens every single time and that lets me finish them before time. But Point 5. arghhhh XD

If not mine, then I will push @taran_1407 to provide editorials.