10642 - Can You Solve It?
Solution Description : This problem is the reverse process of problem 880 - Cantor Fractions So first see the hints of problem 800 - Cantor Fractions In 880: down = (m - up) + 1 Here up = (m - down) + 1 => m = up + down - 1 ------------------------------ so, =>max = m*(m+1)/2 ----------------------------- In 880: up = (max - n) + 1 Here down = (max - n) + 1 => n = max - down + 1 ------------------------------ Input: up1 down1 up2 down2 increment all value i.e. up1++, down1++, up2++, down2++ using equation (i),(ii), and (iii) you can got n1 and n2 print n2-n1 Use long long data type in c for all calculation |
||||||||||