| Title |
User |
Message |
Place |
Date Posted |
| Re: Speeding up exponentiation |
spencereir |
Amazingly, it was a silly logic error that caused the program to never terminate under certain cases. Thank you for your help, though! |
ioi1421 |
Mar 28, 2016 - 11:47:25 pm UTC |
| Re: Speeding up exponentiation |
pyrexshorts |
You are probably using mod too many times, as I see lots of unnecessary mods in your code. Also make sure you are using fast exponentiation in log k time. |
ioi1421 |
Mar 28, 2016 - 10:38:59 pm UTC |
| Re: Hint |
IsaacJL |
Thanks. Classic "don't use global variable" situation. Appreciate it. |
pillaging |
Mar 28, 2016 - 1:35:14 am UTC |
| Re: Hint |
jargon |
Your problem is that you're using global variables. In your first iteration, you have nextOnOther = 2, nextOnSame = 1. This falls to your else case. Your recursion is dfs-like, so you'll go all the wa... |
pillaging |
Mar 28, 2016 - 12:05:18 am UTC |
| Re: Hint |
jargon |
Not possible based on the premise of the recursive case. |
pillaging |
Mar 28, 2016 - 12:03:39 am UTC |
| Re: Hint |
spencereir |
What if nextOnOther AND nextOnSame are -1? EDIT: Ignore, as jargon pointed out, this won't occur, the base case will catch the situation where there is nothing left on either side |
pillaging |
Mar 28, 2016 - 12:00:07 am UTC |
| Speeding up exponentiation |
spencereir |
Does anyone have any hints for speeding up exponentiation modulo a number, or my program's execution in general? I'm achieving a bound of O(n log n), but subtasks 9 and 10 are still giving TLE... |
ioi1421 |
Mar 27, 2016 - 11:57:54 pm UTC |
| Hint |
IsaacJL |
So, I've attempted a few different submissions but all seem to be caught on the same error. I've noticed something interesting with my code and I'm wondering if I could get a small recommendation or h... |
pillaging |
Mar 27, 2016 - 8:23:34 pm UTC |
| Re: Grader giving odd results |
jargon |
Here's a hint: check your compiler warnings. Your code gets AC with the addition of one statement. |
dwitesep09p1 |
Mar 27, 2016 - 12:57:54 am UTC |
| Re: Grader giving odd results |
spencereir |
When this happens it usually means your program is doing something it shouldn't be. The most common causes are accessing arrays out of bounds, which a Windows machine will brush under the carpet, but ... |
dwitesep09p1 |
Mar 26, 2016 - 3:59:13 pm UTC |