so do i have to delete all of the input before showing the output like the one at the site? |
I think you just need to remove the
cout
statements except for the one which gives the final result. Oops - I may have misread the code - there are some lines enclosed in /* */ which I may have not noticed yesterday.
By the way the pow () function is for the maximum and minimum value on the bottom of the explanation but i don't really like to write 1000000, it can confuse me with that many numbers of zeroes so i decided to go with the pow. |
Yes, I eventually realised it was something like that.
However, I think this is a misunderstanding. Those values,
Batasan
1 ≤ N ≤ 106
0 ≤ M, D ≤ 105 |
are there for your guidance when designing your program.
For example the value 10
5 is too large to fit in a 16-bit integer, but will easily fit into a 32-bit integer. This gives you the ability to choose what type of variables to use.
int
will be ok.
Also, if you were considering using an array of such variables, you know there could be up to 10
6 elements in the array. Is such an array feasible? Yes, since each 32-bit integer uses 4 bytes, an array of such ints will use about 4MB of memory, which is perfectly feasible. However it is too large to fit on the stack, you would need to use dynamic memory allocation - I'd use a std::vector but you could also use new / delete too for the dynamic array.
All of those are design criteria, you don't need to write code to test the values, that would be pointless, since the instructions are telling you that the values are
already guaranteed to be within those constraints.
As an aside, if you did need to write a value of 1000000 without risk of confusion over the number of zeros, instead of using the pow() function, simply use scientific notation.
1E6
or
1e6
instead of
pow(10,6)
.