erne.carvajal
BAN USER
Comments (3)
Reputation -5
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
It actually does work, but I'm not sure why. The thing is that in Hexadecimal for example 16^3 is F000 but here 26^3 is more like YYZ, it doesn't even have 4 digits... what's going on?
In 26-base the digits should go form 0 to 25 but here they go from 1 to 26, and the regular transformation algorithm still works, that's confusing.
Comment hidden because of low score. Click to expand.
0
of 0 vote
def print_d(mat, n, m):
for d in range(n + m - 1):
for i in range(max(0, d - m + 1), min(n, d + 1)):
print mat[i][d - i],
print
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Just use modular arithmetic with a large prime. Instead of divide, multiply by the inverse mod(p).
- erne.carvajal March 07, 20141. Calculate tp = the total product mod p
2. For each x: x = tp * x^(p - 2) mod p
note: p must be picked larger than the largest result