#P16511. [GKS 2015 #C] gFiles

    ID: 16488 Type: RemoteJudge 1000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 3 Uploaded By: Tags>数学2015Google Kick Start

[GKS 2015 #C] gFiles

题目描述

Alien tech company G has a very old file transfer tool that is still in use today. While the tool is running, it reassures users by giving status updates on both the percentage of files transferred so far and the number of files transferred so far. The status updates during the process might look like this:

20%20\% ==>>|==>>-------| 11 files transferred

100%100\% ==========|==========| 55 files transferred

But the percentage isn't precise; it is simply truncated before the decimal point (i.e. floored to the next lowest or equal 1%1\%). That is, both 1.2%1.2\% and 1.7%1.7\% would be displayed as 1%1\%.

Some users may want to know the exact total number of files, so you want to modify the tool so that the status updates look like this:

20%20\% ==>>|==>>-------| 11 out of 55 files transferred

100%100\% ==========|==========| 55 out of 55 files transferred

But you've realized that it may or may not be possible to know the number of files. Given the status updates that the tool displays, either figure out how many files there are, or determine that it can't be done (i.e., there are multiple possible values for the number of files). The status updates are not guaranteed to occur at regular intervals and are not guaranteed to occur whenever a file is transferred.

输入格式

The first line contains TT, the number of test cases. TT test cases follow. Each test case consists of one line with an integer NN, the number of status updates output by the tool, followed by NN lines with the format Pi KiP_i \ K_i, where PiP_i and KiK_i are integers representing the percentage and number of files transferred at some point in the process. The updates are given listed in chronological order -- that is, both the PiP_i values and the KiK_i values are nondecreasing throughout a test case.

输出格式

For each case, output a line starts with "Case #x: y", where xx is the number of the case (starting from 1), and yy is either the total number of files, or 1-1 if that number is ambiguous.

3
2
20 1
100 5
10
25 241
27 262
43 407
44 413
57 536
64 601
67 637
84 789
95 893
96 903
10
0 0
8 2
8 2
17 4
30 7
39 9
69 16
73 17
82 19
91 21
Case #1: 5
Case #2: -1
Case #3: 23

提示

Limits

1T501 \le T \le 50.

1N1001 \le N \le 100.

0Pi1000 \le P_i \le 100

Small dataset (Test Set 1 - Visible)

0Ki20000 \le K_i \le 2000

The answer is guaranteed not to exceed 20002000.

Large dataset (Test Set 2 - Hidden)

0Ki10150 \le K_i \le 10^{15}

The answer is guaranteed not to exceed 101510^{15}.