Lili is practicing using her favorite character Templor Assasson. Templor Assasson has 100 base damage and 0 bonus damage at start. For each hit, bonus damage increase by 50. Lili wants to know the total damage of Templor Assasson after N hit(s).
Format input : given 1 line consist of 1 integer N the number of hit(s) of Templor Assasson.
Format output : output one number that describe the total damage of Templor Assasson.
Constraints : 1<=N<=1000000
This is the formula for calculating his attack power based on the word problem. However, the input and output provided doesn't match. 3 hits should mean his attack power is 250 rather than 450 - so you should figure out whether the sample is incorrect or the word problem.
The constraint is easy enough to do, just test whether or not "N" is bigger than 1 and less than 1000000 with an if statement or as the loop condition if you're using that.
My advice is to just start coding, even if you have no idea what to code.
This equation also equals 450, where did you get the numbers from? If you do the math a very certain way, it works, but that's not the method explained in the description of the problem, which is why I asked them to recheck.
The only way I can imagine you getting 100, 150, and then 200 is via a round-about method that wouldn't actually reflect the word problem which says clearly "For EACH hit, bonus damage increases by 50." It doesn't indicate that it's an exponential function, which also wouldn't work.
I suppose that's one way of reading it - but it still makes no sense. "N" is the number of hits, meaning 3 shouldn't mean 2 hits + 1 no hit.
It doesn't imply a quadratic function either from what I've read. I was following you until you decided to add all the numbers together, I don't see how total damage could refer to that.
Even if it did refer to doing the math in this way, it, again, wouldn't make sense. For each hit, his bonus attack goes up by 50. And then it states that "N" is the number of hits. Doing what you did would mean that after 0 hits, he's at 100 damage. And that at 1 hit... he's still at 100 damage. That doesn't make sense.
Something in the problem isn't correctly stated or the sample is incorrect.
No, @Alyssa11, you shouldn't use a loop. After all, N could be as big as a million. You've been given the sum of this particular arithmetic series. Just output the result of that formula ... one line of code ... O(1) time complexity.