1382 - Sum of Cubes

Discussion around the problems of the COJ.
Forum rules
Remember that posting AC code is not allowed here. If you are going to ask a question or to post a solution, describe your algorithm instead. Posting AC code will be penalized.
Post Reply
User avatar
dovier
Posts: 1143
Joined: 7 years ago
Location: Havana, Cuba
Gender: Male
Cuba

1382 - Sum of Cubes

Post by dovier » 7 years ago




axlluis
Posts: 17
Joined: 7 years ago
Gender: None specified

Re: 1382 - Sum of Cubes

Post by axlluis » 7 years ago

Hi , i have problems with problems that requires a result MOD -some number - , because i dont understand MOD to well, the user phantom tell me that the MOD is the rest of the division of to numbers, but in this problem for the input 1 1000000000000000000 i aply this thing and give me a negative value, can any body explainme what for 1 1000000000000000000 the result is 441??

User avatar
ymondelo20
Posts: 1968
Joined: 7 years ago
Location: Universidad de las Ciencias Informáticas
Gender: None specified
Contact:

Re: 1382 - Sum of Cubes

Post by ymondelo20 » 7 years ago

A naive problem, the module (the rest of the integer division, in this case by 1000007) of any number can't be negative... the value will be always between 0 and the MODULE VALUE - 1 (0 and 1000006 for this problem). If you get a negative result, then probably you are using a wrong type of variable (INT instead LONG LONG in C/C++ for example).
"Every problem has a simple, fast and wrong solution" OJ's Main Law. ;)

Post Reply

Return to “Problem set”