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
  • 相关阅读:
    P1613 跑路
    数据挖掘-聚类分析(Python实现K-Means算法)
    使用scikit-learn 估计器分类
    数据挖掘-集成学习
    数据挖掘-关联分析 Apriori算法和FP-growth 算法
    scikit-learn 中常用的评估模型
    数据挖掘---支持向量机(SVM)
    数据挖掘-KNN-K最近邻算法
    数据挖掘-决策树
    数据挖掘-逻辑Logistic回归
  • 原文地址:https://www.cnblogs.com/cdyboke/p/6828164.html
Copyright © 2011-2022 走看看