You are given an integer number S. You can transform any integer number A to another integer number B by adding x to A. This x is an integer number which is a prime factor of A (Please note that 1 and A are not being considered as a factor of A). Now, your task is to find the minimum number of transformations required to transform S to another integer number T .
For each test case, there will be a line with two integers, S (1 ≤ S ≤ 100) & T (1 ≤ T ≤ 1000), as described above. The last test case will be followed by a line with two 0’s denoting end of input. This case should not be processed.
For every test case except the last one, print a line of the form ‘Case X: Y ’ where X is the serial number of output (starting from 1). Y is the minimum number of transformations required to transform S to T . If it is not possible to make T from S with the given rules, Y shall be ‘-1’. Explanation of case 1: You can make 12 from 6 in 2 steps in this way: 6 → 9 → 12.
範例輸入 1
6 12 6 13 0 0
範例輸出 1
Case 1: 2 Case 2: -1
Pro 專屬功能: 查看這題在歷屆 CPE 出現過幾次 — 升級以解鎖.