zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    Java总结篇系列:Java泛型
    视图、索引、存储过程优缺点
    SQL之case when then用法
    oracle数据库表的导入导出cmd命令大全
    ORA-01652:无法通过128(在表空间temp中)扩展temp段 解决方法
    如何查看一个数据文件是否是自动扩展
    ora-01652无法通过128(在表空间temp中)扩展temp段
    解决ora-01652无法通过128(在temp表空间中)扩展temp段的过程
    Java中的JDBC基础
    Java中的Property类
  • 原文地址:https://www.cnblogs.com/cdyboke/p/6828164.html
Copyright © 2011-2022 走看看