I do not understand the importance of redefining the range of n in the two subtasks, when already it is given that n ranges between 1 to 10^5.
Please explain the importance of redefining the two sub-tasks in the problem.
I do not understand the importance of redefining the range of n in the two subtasks, when already it is given that n ranges between 1 to 10^5.
Please explain the importance of redefining the two sub-tasks in the problem.
Constraints and Subtasks are two different things!
Constraints
It tells about range of inputs and testcases, maximum size of the array you require to solve the problem, maximum length of string etc.
The input values will always be within the said range of the constraints.
Subtasks
Subtasks are different set of testcases to check your code efficiency and Time constraints.
Every problems has subtasks it really helps during Competition you can check for which range of inputs my solution is not working.
An example,
Problem : Find and print a^b where a and b are given as input.
Constraints : 1 <= a,b <= 10^{1000}
Subtasks :
Subtask 1, points 10 => 1 <= a,b <= 10
Subtask 2, points 15 => 1 <= a <= 10 ; 1 <= b <= 10^5
Subtask 3, points 30 => 1 <= a,b <= 10^9
Subtask 4, points 45 => **Original constraint **
Here the constraints say that the input values of both a and b will be more than 0 but upto 10^{1000}.
Here if you use just int datatype and build-in power function, than you will easily pass subtask 1 and 2 and get a total of 10 + 15 = 25 points.
But the int datatype is not sufficient when a and b has values of the range 10^9, so you need some different approach. If you solve this then it ( including subtask 1 and 2 at the same time ) will fetch you 10 + 15 + 30 = 55 points.
And if you solved the last subtask which has a and b values in range of 10^{1000} ( thats huge, use arrays maybe !! ) including previous subtasks at the same time then you will get full marks !! ( 100 points ).
But solving only each subtask individually will not give you the points from other subtasks.
nicely explained!