The list of heights is a subset of the DD values in the given lists. The solution is given below:

  • Sort the given divisors list in strictly decreasing order of D values.

  • Iterate over the pairs from the beginning of the sorted list. For each DiD_{i}decrease the value of FjF_{j} by FiF_{i}where Di0modDjD_{i} \equiv 0 \mod D_{j} and DiDjD_{i} \neq D_{j}

  • After that print the pairs where Fi>0F_{i} > 0 in strictly increasing order of DiD_{i}

Statistics

73% Solution Ratio
fextivityEarliest, Apr '21
dream.toFastest, 0.2s
Tahmid690Lightest, 8.8 MB
Deshi_TouristShortest, 848B
Toph uses cookies. By continuing you agree to our Cookie Policy.