• B


    Given 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD(x, y) = k. GCD(x, y) means the greatest common divisor of x and y. Since the number of choices may be very large, you're only required to output the total number of different number pairs. 
    Please notice that, (x=5, y=7) and (x=7, y=5) are considered to be the same. 

    Yoiu can assume that a = c = 1 in all test cases. 

    InputThe input consists of several test cases. The first line of the input is the number of the cases. There are no more than 3,000 cases. 
    Each case contains five integers: a, b, c, d, k, 0 < a <= b <= 100,000, 0 < c <= d <= 100,000, 0 <= k <= 100,000, as described above. 
    OutputFor each test case, print the number of choices. Use the format in the example. 
    Sample Input

    2
    1 3 1 5 1
    1 11014 1 14409 9

    Sample Output

    Case 1: 9
    Case 2: 736427
    
    
            
     

    Hint

    For the first sample input, all the 9 pairs of numbers are (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 5), (3, 4), (3, 5).
     1 Given 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD(x, y) = k. GCD(x, y) means the greatest common divisor of x and y. Since the number of choices may be very large, you're only required to output the total number of different number pairs. 
     2 Please notice that, (x=5, y=7) and (x=7, y=5) are considered to be the same. 
     3 
     4 Yoiu can assume that a = c = 1 in all test cases. 
     5 Input
     6 The input consists of several test cases. The first line of the input is the number of the cases. There are no more than 3,000 cases. 
     7 Each case contains five integers: a, b, c, d, k, 0 < a <= b <= 100,000, 0 < c <= d <= 100,000, 0 <= k <= 100,000, as described above. 
     8 Output
     9 For each test case, print the number of choices. Use the format in the example. 
    10 Sample Input
    11 2
    12 1 3 1 5 1
    13 1 11014 1 14409 9
    14 Sample Output
    15 Case 1: 9
    16 Case 2: 736427
    17 
    18 
    19         
    20   
    21 Hint
    22 For the first sample input, all the 9 pairs of numbers are (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 5), (3, 4), (3, 5).
    AC 15ms
  • 相关阅读:
    Ajax一个好用简单框架Ajax.dll_________推荐
    米亚罗、理县、都江堰和青城山的灾前照片
    PlatForm在国家卫星气象中心
    CN Grid 项目
    IDL与matlab比较【转】
    家乡宁国
    ISPRS感受
    .NET 连接 Oracle
    编程实现Google Earth和ArcGIS的联动[demo]
    IDL 与 外部语言的几种集成方式(一)——connector
  • 原文地址:https://www.cnblogs.com/cdyboke/p/6828164.html
Copyright © 2020-2023  润新知