Preparing NOJ # GCD

3000ms 32768K

## Description:

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.

## Input:

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.
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.

## Output:

For 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

HintFor 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). 

## Note:

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).

Info Provider HDU

Code HDU1695

Tags

Submitted 87

Passed 28

AC Rate 32.18%

Date 06/03/2019 16:22:30

Related

Nothing Yet
{"ft_lang_label":"__label__en","ft_lang_prob":0.8317423,"math_prob":0.9966334,"size":1128,"snap":"2021-21-2021-25","text_gpt3_token_len":422,"char_repetition_ratio":0.12989324,"word_repetition_ratio":0.23728813,"special_character_ratio":0.43705675,"punctuation_ratio":0.27190334,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99701387,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,3,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-05-12T20:46:13Z\",\"WARC-Record-ID\":\"<urn:uuid:2fc6294d-209d-42d9-8fd6-456fc8e8503a>\",\"Content-Length\":\"44520\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:0767e5cd-a369-4b50-b3b6-f979b6e36565>\",\"WARC-Concurrent-To\":\"<urn:uuid:af890c39-7eeb-45d4-9817-8d6417f2d675>\",\"WARC-IP-Address\":\"180.209.96.50\",\"WARC-Target-URI\":\"https://acm.njupt.edu.cn/problem/HDU1695\",\"WARC-Payload-Digest\":\"sha1:M23IV3GKCT2TXBCNNWWIOHXG3Z4TQHNB\",\"WARC-Block-Digest\":\"sha1:4JQJXIXLK2C6LFBPRGF2STTAJVO4IVLI\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-21/CC-MAIN-2021-21_segments_1620243989705.28_warc_CC-MAIN-20210512193253-20210512223253-00098.warc.gz\"}"}