Doubt in CSES Problem(Factory Machines)

Are you stuck at “how do I turn my thoughts into code”, “how do I write code” (like the specifics of STL), or both

1 Like

Mostly This:how do I turn my thoughts into code.

But Sometimes Second one is also a problem with me.(First one is main)

I guess you could start with some process to get your ideas from your mind to your code - for example, write out all formulas/stuff by hand, then write out very broad pseudocode (like “read input”, “compute the angle”, etc.), then start fleshing out the details and stuff. Eventually you should get the hang of it, then eventually be able to skip a step or two, and by the end the code will come naturally.

To get over STL issues, you’ll just have to dive into the deep end and get experience with it. Also don’t be scared by crazy long compiler errors, sometimes it just means you have a mistake as simple as taking max(long long, int) or something.

I’m not going to pretend that my advice is backed by experience (because I picked coding up quickly, being a fast learner etc.) but this is what I would do (probably) if I were stuck.

2 Likes

Thank You So much for the advice.I think Practice is the only sword for it!

1 Like

I wish you become Red in Today’s Lunchtime.Thanks for your time legend! @galencolin

@galencolin i was doing the same problem but failing for 1 test case ,can you tell me why this is not working.

Edit: @galencolin sorry ,the previous link was not working .

1 Like

@sumitj1 The Problem in your code is that your sum variable got overflowed.
i Put your if condition inside the incremental loop of sum.
Inside the loop if the “if” condition got satisfied the loop will break and overflow will not occur.

Here is your AC code- Click Here

1 Like

Welcome buddy!