• [C] Adding Prime

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • In this problem, 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.
  • 输入
  • Input starts with an integer T (≤ 500), denoting the number of test cases.

    Each case contains two integers: s (1 ≤ s ≤ 100) and t (1 ≤ t ≤ 1000).
  • 输出
  • For each case, print the case number and the minimum number of transformations needed. If it's impossible, then print -1.
  • 样例输入
  • 2
    6 12
    6 13
    
  • 样例输出
  • Case 1: 2
    Case 2: -1
    
  • 提示
  • 来源
  • Hungar
  • 操作

显示春菜