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
  • 相关阅读:
    转: winform间的传值并linklabel动态窗口跳转
    app.config配置
    RSS2.0中文规范
    windows forms 窗口跳转
    C#对DataGridView进行添加、修改、删除数据操作
    小小一颗心
    小记上海一天
    又一个婉约的日子
    七夕节
    我的实习
  • 原文地址:https://www.cnblogs.com/cdyboke/p/6828164.html
Copyright © 2011-2022 走看看