05.11.2015, 11:47
(
Последний раз редактировалось Macluawn; 05.11.2015 в 17:11.
)
True, although for small values you won`t have a problem.
But if you must..if you know the maximum level before hand, DP can be used (dynamic programming)
EDIT:
In this case the array isn`t even needed.
But if you must..if you know the maximum level before hand, DP can be used (dynamic programming)
pawn Код:
levelPoints(level)
{
new points[100];
points[0] = 0;
for(new i=1; i <= level; ++i) {
points[i] = points[i-1] + 10*i;
}
return points[level];
}
In this case the array isn`t even needed.
pawn Код:
levelPoints(level)
{
new points = 0;
for(new i=1; i <= level; ++i) {
points += 10*i;
}
return points;
}