Editorial for ICPC NEERC 2010 B - Binary Operation


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
  • Write a procedure to compute for single digits: \displaystyle a_0 \times \underbrace{a \times a \times \dots \times a}_{c\text{ times}}
    • Repeat multiplies until it loops (after at most 10 muls)
    • Use offset and period length to compute the result
  • Write a procedure to compute for single digits: \displaystyle a_0 \times \underbrace{a' \times (a+1)' \times \dots \times b'}_{d\text{ times}} where +1 wraps to 0; and a' means "a \times a \times \dots \times a" c times (as above)
    • Compute loop similarly (can be as long as 100)
  • Compute the result digit by digit using two of the above procedures
    • For a digit i, round the number a up and b down to the nearest multiple of 10^i
    • Represent the number range [a, b] as:
      • X \dots XXaXX \dots X
      • X \dots XX(a+1)00 \dots 0
      • X \dots XXb00 \dots 0
      • X \dots XXbXX \dots X

Comments

There are no comments at the moment.