2015 Problems
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +5 -0
- 2015/finals/fox_blocks.html +77 -0
- 2015/finals/fox_blocks.in +3 -0
- 2015/finals/fox_blocks.md +59 -0
- 2015/finals/fox_blocks.out +20 -0
- 2015/finals/fox_focks.html +59 -0
- 2015/finals/fox_focks.in +3 -0
- 2015/finals/fox_focks.md +52 -0
- 2015/finals/fox_focks.out +20 -0
- 2015/finals/fox_hawks.html +94 -0
- 2015/finals/fox_hawks.in +3 -0
- 2015/finals/fox_hawks.md +78 -0
- 2015/finals/fox_hawks.out +20 -0
- 2015/finals/fox_lochs.html +57 -0
- 2015/finals/fox_lochs.in +281 -0
- 2015/finals/fox_lochs.md +44 -0
- 2015/finals/fox_lochs.out +20 -0
- 2015/finals/fox_locks.html +74 -0
- 2015/finals/fox_locks.in +0 -0
- 2015/finals/fox_locks.md +67 -0
- 2015/finals/fox_locks.out +20 -0
- 2015/quals/cooking_the_books.html +45 -0
- 2015/quals/cooking_the_books.in +101 -0
- 2015/quals/cooking_the_books.md +30 -0
- 2015/quals/cooking_the_books.out +100 -0
- 2015/quals/laser_maze.html +68 -0
- 2015/quals/laser_maze.in +0 -0
- 2015/quals/laser_maze.md +48 -0
- 2015/quals/laser_maze.out +100 -0
- 2015/quals/new_years_resolution.html +41 -0
- 2015/quals/new_years_resolution.in +1006 -0
- 2015/quals/new_years_resolution.md +31 -0
- 2015/quals/new_years_resolution.out +48 -0
- 2015/round1/autocomplete.html +54 -0
- 2015/round1/autocomplete.in +3 -0
- 2015/round1/autocomplete.md +41 -0
- 2015/round1/autocomplete.out +26 -0
- 2015/round1/corporate_gifting.html +79 -0
- 2015/round1/corporate_gifting.in +3 -0
- 2015/round1/corporate_gifting.md +68 -0
- 2015/round1/corporate_gifting.out +34 -0
- 2015/round1/homework.html +42 -0
- 2015/round1/homework.in +101 -0
- 2015/round1/homework.md +48 -0
- 2015/round1/homework.out +100 -0
- 2015/round1/winning_at_sports.html +61 -0
- 2015/round1/winning_at_sports.in +101 -0
- 2015/round1/winning_at_sports.md +45 -0
- 2015/round1/winning_at_sports.out +100 -0
- 2015/round2/all_critical.html +57 -0
.gitattributes
CHANGED
@@ -58,3 +58,8 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
58 |
2014/finals/intervals_of_love.in filter=lfs diff=lfs merge=lfs -text
|
59 |
2014/finals/lunch_at_facebook.in filter=lfs diff=lfs merge=lfs -text
|
60 |
2014/finals/tours.in filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
58 |
2014/finals/intervals_of_love.in filter=lfs diff=lfs merge=lfs -text
|
59 |
2014/finals/lunch_at_facebook.in filter=lfs diff=lfs merge=lfs -text
|
60 |
2014/finals/tours.in filter=lfs diff=lfs merge=lfs -text
|
61 |
+
2015/finals/fox_blocks.in filter=lfs diff=lfs merge=lfs -text
|
62 |
+
2015/finals/fox_focks.in filter=lfs diff=lfs merge=lfs -text
|
63 |
+
2015/finals/fox_hawks.in filter=lfs diff=lfs merge=lfs -text
|
64 |
+
2015/round1/autocomplete.in filter=lfs diff=lfs merge=lfs -text
|
65 |
+
2015/round1/corporate_gifting.in filter=lfs diff=lfs merge=lfs -text
|
2015/finals/fox_blocks.html
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p>
|
2 |
+
Today, Mr. Fox is taking it easy by playing with some blocks in a 2D world. Each block is an inch-by-inch square,
|
3 |
+
and there are <strong>N</strong> stacks of blocks in a row, with the <strong>i</strong>th stack having <strong>H<sub>i</strong> blocks.
|
4 |
+
For example, if <strong>N</strong>=6 and <strong>H</strong>={3, 1, 5, 4, 1, 6}, then the collection of blocks looks like this
|
5 |
+
(where an "X" denotes a block):
|
6 |
+
<p>
|
7 |
+
|
8 |
+
<p>
|
9 |
+
<pre>
|
10 |
+
.....X
|
11 |
+
..X..X
|
12 |
+
..XX.X
|
13 |
+
X.XX.X
|
14 |
+
X.XX.X
|
15 |
+
XXXXXX
|
16 |
+
</pre>
|
17 |
+
</p>
|
18 |
+
|
19 |
+
<p>
|
20 |
+
Ever curious, Mr. Fox would like to answer <strong>Q</strong> questions about his blocks (without actually modifying them),
|
21 |
+
the <strong>i</strong>th one being as follows:
|
22 |
+
</p>
|
23 |
+
|
24 |
+
<p>
|
25 |
+
"If I were to consider only the stacks from <strong>A<sub>i</sub></strong> to <strong>B<sub>i</sub></strong> inclusive,
|
26 |
+
getting rid of all of the other blocks, how many square inches of water would my block structure be able to hold?"
|
27 |
+
</p>
|
28 |
+
|
29 |
+
<p>
|
30 |
+
As one might imagine, a given square inch can hold water if it doesn't contain a block itself, but there is a block both somewhere to its left
|
31 |
+
and somewhere to its right at the same height. For example, if you were to take
|
32 |
+
<strong>A<sub>i</sub></strong>=2 and <strong>B<sub>i</sub></strong>=6, you would be left with the
|
33 |
+
following block structure to consider (where an "*" denotes an inch-by-inch square which can hold water):
|
34 |
+
</p>
|
35 |
+
|
36 |
+
<p>
|
37 |
+
<pre>
|
38 |
+
....X
|
39 |
+
.X**X
|
40 |
+
.XX*X
|
41 |
+
.XX*X
|
42 |
+
.XX*X
|
43 |
+
XXXXX
|
44 |
+
</pre>
|
45 |
+
</p>
|
46 |
+
|
47 |
+
|
48 |
+
<h3>Constraints</h3>
|
49 |
+
<p>
|
50 |
+
1 ≤ <strong>T</strong> ≤ 20 <br/>
|
51 |
+
1 ≤ <strong>N</strong> ≤ 300,000 <br />
|
52 |
+
1 ≤ <strong>Q</strong> ≤ 300,000 <br />
|
53 |
+
1 ≤ <strong>H<sub>i</sub></strong> ≤ 10<sup>9</sup> <br />
|
54 |
+
1 ≤ <strong>A<sub>i</sub></strong> ≤ <strong>B<sub>i</sub></strong> ≤ <strong>N</strong> <br />
|
55 |
+
</p>
|
56 |
+
|
57 |
+
|
58 |
+
<h3>Input</h3>
|
59 |
+
<p>
|
60 |
+
Input begins with an integer <strong>T</strong>, the number of block structures Mr. Fox has.
|
61 |
+
For each structure, there is first a line containing the space-separated integers <strong>N</strong> and <strong>Q</strong>.
|
62 |
+
The next line contains the space-separated integers <strong>H<sub>i</sub></strong>.
|
63 |
+
Then follow <strong>Q</strong> lines, the <strong>i</strong>th of which contains the space-separated integers
|
64 |
+
<strong>A<sub>i</sub></strong> and <strong>B<sub>i</sub></strong>.
|
65 |
+
</p>
|
66 |
+
|
67 |
+
|
68 |
+
<h3>Output</h3>
|
69 |
+
<p>
|
70 |
+
For the <strong>i</strong>th structure, print a line containing "Case #<strong>i</strong>: " followed by
|
71 |
+
the sum of the answers to the <strong>Q</strong> questions modulo 10<sup>9</sup>+7.
|
72 |
+
</p>
|
73 |
+
|
74 |
+
<h3>Explanation of Sample</h3>
|
75 |
+
<p>
|
76 |
+
In the first case, we consider prefixes of the block structure. The answers to the queries are 0, 0, 0, 0, 0, 5, 5, 7, 7, 18, 18 for a total of 60.
|
77 |
+
</p>
|
2015/finals/fox_blocks.in
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:69c748bc3d1a448fe7f376cb4cacd7b4eefae27a6aa2103899f4da2919c6b233
|
3 |
+
size 27832483
|
2015/finals/fox_blocks.md
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Today, Mr. Fox is taking it easy by playing with some blocks in a 2D world.
|
2 |
+
Each block is an inch-by-inch square, and there are **N** stacks of blocks in
|
3 |
+
a row, with the **i**th stack having **Hi** blocks. For example, if **N**=6
|
4 |
+
and **H**={3, 1, 5, 4, 1, 6}, then the collection of blocks looks like this
|
5 |
+
(where an "X" denotes a block):
|
6 |
+
|
7 |
+
.....X
|
8 |
+
..X..X
|
9 |
+
..XX.X
|
10 |
+
X.XX.X
|
11 |
+
X.XX.X
|
12 |
+
XXXXXX
|
13 |
+
|
14 |
+
Ever curious, Mr. Fox would like to answer **Q** questions about his blocks
|
15 |
+
(without actually modifying them), the **i**th one being as follows:
|
16 |
+
|
17 |
+
"If I were to consider only the stacks from **Ai** to **Bi** inclusive,
|
18 |
+
getting rid of all of the other blocks, how many square inches of water would
|
19 |
+
my block structure be able to hold?"
|
20 |
+
|
21 |
+
As one might imagine, a given square inch can hold water if it doesn't contain
|
22 |
+
a block itself, but there is a block both somewhere to its left and somewhere
|
23 |
+
to its right at the same height. For example, if you were to take **Ai**=2 and
|
24 |
+
**Bi**=6, you would be left with the following block structure to consider
|
25 |
+
(where an "*" denotes an inch-by-inch square which can hold water):
|
26 |
+
|
27 |
+
....X
|
28 |
+
.X**X
|
29 |
+
.XX*X
|
30 |
+
.XX*X
|
31 |
+
.XX*X
|
32 |
+
XXXXX
|
33 |
+
|
34 |
+
### Constraints
|
35 |
+
|
36 |
+
1 ≤ **T** ≤ 20
|
37 |
+
1 ≤ **N** ≤ 300,000
|
38 |
+
1 ≤ **Q** ≤ 300,000
|
39 |
+
1 ≤ **Hi** ≤ 109
|
40 |
+
1 ≤ **Ai** ≤ **Bi** ≤ **N**
|
41 |
+
|
42 |
+
### Input
|
43 |
+
|
44 |
+
Input begins with an integer **T**, the number of block structures Mr. Fox
|
45 |
+
has. For each structure, there is first a line containing the space-separated
|
46 |
+
integers **N** and **Q**. The next line contains the space-separated integers
|
47 |
+
**Hi**. Then follow **Q** lines, the **i**th of which contains the space-
|
48 |
+
separated integers **Ai** and **Bi**.
|
49 |
+
|
50 |
+
### Output
|
51 |
+
|
52 |
+
For the **i**th structure, print a line containing "Case #**i**: " followed by
|
53 |
+
the sum of the answers to the **Q** questions modulo 109+7.
|
54 |
+
|
55 |
+
### Explanation of Sample
|
56 |
+
|
57 |
+
In the first case, we consider prefixes of the block structure. The answers to
|
58 |
+
the queries are 0, 0, 0, 0, 0, 5, 5, 7, 7, 18, 18 for a total of 60.
|
59 |
+
|
2015/finals/fox_blocks.out
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Case #1: 60
|
2 |
+
Case #2: 27
|
3 |
+
Case #3: 31
|
4 |
+
Case #4: 0
|
5 |
+
Case #5: 9
|
6 |
+
Case #6: 0
|
7 |
+
Case #7: 824489226
|
8 |
+
Case #8: 228416209
|
9 |
+
Case #9: 14231442
|
10 |
+
Case #10: 31749050
|
11 |
+
Case #11: 871842030
|
12 |
+
Case #12: 496227686
|
13 |
+
Case #13: 740455790
|
14 |
+
Case #14: 687834190
|
15 |
+
Case #15: 415275284
|
16 |
+
Case #16: 815170510
|
17 |
+
Case #17: 737257432
|
18 |
+
Case #18: 204464835
|
19 |
+
Case #19: 550439741
|
20 |
+
Case #20: 328256461
|
2015/finals/fox_focks.html
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p>
|
2 |
+
Mr. Fox has opened up a fabulous Fock farm! A Fock is a cute little animal which can have either red, green, or blue fur
|
3 |
+
(these 3 possible colors can be numbered 1, 2, and 3, respectively). Furthermore, a Fock's fur color can change every second!
|
4 |
+
</p>
|
5 |
+
|
6 |
+
<p>
|
7 |
+
Mr. Fox owns a flock of <strong>N</strong> Focks, with the <strong>i</strong>th one initially having a color of <strong>C<sub>i</sub></strong>.
|
8 |
+
Every second, if the <strong>i</strong>th Fock currently has a color of <strong>a</strong>, it will switch to having a color of <strong>b</strong>
|
9 |
+
for the next second with probability <strong>P<sub>i,a,b</sub></strong>%. All Focks change color simultaneously.
|
10 |
+
</p>
|
11 |
+
|
12 |
+
<p>
|
13 |
+
After a very large amount of time has gone by, Mr. Fox will take a single photo of all of his Focks to help advertise his farm.
|
14 |
+
In particular, he picks an integer <strong>t</strong> at uniform random from the range [10<sup>100</sup>, 10<sup>1000</sup>] and waits that many seconds.
|
15 |
+
He's hoping that the photo will make it look like his farm has a well-balanced mix of Fock colors — it'll be no good if the photo ends up
|
16 |
+
featuring a strict majority of a single color (that is, strictly more than <strong>N</strong>/2 of the Focks having the same color).
|
17 |
+
What's the probability of this occurring?
|
18 |
+
</p>
|
19 |
+
|
20 |
+
|
21 |
+
|
22 |
+
<h3>Constraints</h3>
|
23 |
+
<p>
|
24 |
+
1 ≤ <strong>T</strong> ≤ 20<br />
|
25 |
+
1 ≤ <strong>N</strong> ≤ 50,000<br />
|
26 |
+
1 ≤ <strong>C<sub>i</sub></strong> ≤ 3 for all <strong>i</strong><br />
|
27 |
+
0 ≤ <strong>P<sub>i,a,b</sub></strong> ≤ 100
|
28 |
+
for all <strong>i</strong>, <strong>a</strong> and <strong>b</strong><br />
|
29 |
+
<strong>P<sub>i,a,1</sub></strong> + <strong>P<sub>i,a,2</sub></strong> + <strong>P<sub>i,a,3</sub></strong> = 100
|
30 |
+
for all <strong>i</strong> and <strong>a</strong><br />
|
31 |
+
</p>
|
32 |
+
|
33 |
+
<h3>Input</h3>
|
34 |
+
<p>
|
35 |
+
Input begins with an integer <strong>T</strong>, the number of Fock farms Mr. Fox has.
|
36 |
+
For each farm, there is first a line containing the integer <strong>N</strong>.
|
37 |
+
Then, for each Fock <strong>i</strong>, 4 lines follow.
|
38 |
+
The first of these lines contains the integer <strong>C<sub>i</sub></strong>.
|
39 |
+
The next three lines contain three space-separated integers each, with the <strong>b</strong>th integer on the <strong>a</strong>th line being
|
40 |
+
<strong>P<sub>i,a,b</sub></strong>.
|
41 |
+
</p>
|
42 |
+
|
43 |
+
|
44 |
+
<h3>Output</h3>
|
45 |
+
<p>
|
46 |
+
For the <strong>i</strong>th farm, print a line containing "Case #<strong>i</strong>: " followed by
|
47 |
+
the probability that the <strong>i</strong>th picture contains a strict majority of some color of Fock, rounded to 6 decimal places.
|
48 |
+
</p>
|
49 |
+
|
50 |
+
<p>
|
51 |
+
Absolute errors of up to 2e-6 will be ignored.
|
52 |
+
</p>
|
53 |
+
|
54 |
+
<h3>Explanation of Sample</h3>
|
55 |
+
<p>
|
56 |
+
In the first case, the first Fock never changes color, so it'll still have color 1 in the photo.
|
57 |
+
The second Fock is likely to have color 2 for a while, but by the time the photo is taken, it'll certainly have color 3.
|
58 |
+
The third Fock will have either color 2 or 3 in the photo, with equal probability. Therefore, the photo will have a 50% chance of having a strict majority of color 3, and a 50% chance of no strict majority.
|
59 |
+
</p>
|
2015/finals/fox_focks.in
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bf3025efbfee6b3d52c0372283c0712b33eab850e808172bd5c830b61e17610c
|
3 |
+
size 17889224
|
2015/finals/fox_focks.md
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Mr. Fox has opened up a fabulous Fock farm! A Fock is a cute little animal
|
2 |
+
which can have either red, green, or blue fur (these 3 possible colors can be
|
3 |
+
numbered 1, 2, and 3, respectively). Furthermore, a Fock's fur color can
|
4 |
+
change every second!
|
5 |
+
|
6 |
+
Mr. Fox owns a flock of **N** Focks, with the **i**th one initially having a
|
7 |
+
color of **Ci**. Every second, if the **i**th Fock currently has a color of
|
8 |
+
**a**, it will switch to having a color of **b** for the next second with
|
9 |
+
probability **Pi,a,b**%. All Focks change color simultaneously.
|
10 |
+
|
11 |
+
After a very large amount of time has gone by, Mr. Fox will take a single
|
12 |
+
photo of all of his Focks to help advertise his farm. In particular, he picks
|
13 |
+
an integer **t** at uniform random from the range [10100, 101000] and waits
|
14 |
+
that many seconds. He's hoping that the photo will make it look like his farm
|
15 |
+
has a well-balanced mix of Fock colors — it'll be no good if the photo ends up
|
16 |
+
featuring a strict majority of a single color (that is, strictly more than
|
17 |
+
**N**/2 of the Focks having the same color). What's the probability of this
|
18 |
+
occurring?
|
19 |
+
|
20 |
+
### Constraints
|
21 |
+
|
22 |
+
1 ≤ **T** ≤ 20
|
23 |
+
1 ≤ **N** ≤ 50,000
|
24 |
+
1 ≤ **Ci** ≤ 3 for all **i**
|
25 |
+
0 ≤ **Pi,a,b** ≤ 100 for all **i**, **a** and **b**
|
26 |
+
**Pi,a,1** \+ **Pi,a,2** \+ **Pi,a,3** = 100 for all **i** and **a**
|
27 |
+
|
28 |
+
### Input
|
29 |
+
|
30 |
+
Input begins with an integer **T**, the number of Fock farms Mr. Fox has. For
|
31 |
+
each farm, there is first a line containing the integer **N**. Then, for each
|
32 |
+
Fock **i**, 4 lines follow. The first of these lines contains the integer
|
33 |
+
**Ci**. The next three lines contain three space-separated integers each, with
|
34 |
+
the **b**th integer on the **a**th line being **Pi,a,b**.
|
35 |
+
|
36 |
+
### Output
|
37 |
+
|
38 |
+
For the **i**th farm, print a line containing "Case #**i**: " followed by the
|
39 |
+
probability that the **i**th picture contains a strict majority of some color
|
40 |
+
of Fock, rounded to 6 decimal places.
|
41 |
+
|
42 |
+
Absolute errors of up to 2e-6 will be ignored.
|
43 |
+
|
44 |
+
### Explanation of Sample
|
45 |
+
|
46 |
+
In the first case, the first Fock never changes color, so it'll still have
|
47 |
+
color 1 in the photo. The second Fock is likely to have color 2 for a while,
|
48 |
+
but by the time the photo is taken, it'll certainly have color 3. The third
|
49 |
+
Fock will have either color 2 or 3 in the photo, with equal probability.
|
50 |
+
Therefore, the photo will have a 50% chance of having a strict majority of
|
51 |
+
color 3, and a 50% chance of no strict majority.
|
52 |
+
|
2015/finals/fox_focks.out
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Case #1: 0.500000
|
2 |
+
Case #2: 0.000000
|
3 |
+
Case #3: 1.000000
|
4 |
+
Case #4: 0.777778
|
5 |
+
Case #5: 0.812282
|
6 |
+
Case #6: 1.000000
|
7 |
+
Case #7: 0.333333
|
8 |
+
Case #8: 0.511290
|
9 |
+
Case #9: 0.333334
|
10 |
+
Case #10: 0.590398
|
11 |
+
Case #11: 0.526490
|
12 |
+
Case #12: 0.333333
|
13 |
+
Case #13: 0.333333
|
14 |
+
Case #14: 0.510803
|
15 |
+
Case #15: 0.333334
|
16 |
+
Case #16: 0.333334
|
17 |
+
Case #17: 0.515045
|
18 |
+
Case #18: 0.518484
|
19 |
+
Case #19: 0.333334
|
20 |
+
Case #20: 0.511119
|
2015/finals/fox_hawks.html
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p>
|
2 |
+
Mr. Fox always puts aside some time on the weekends to practice his falconry. Mr. Fox owns <strong>N</strong> hawks, numbered from
|
3 |
+
1 to <strong>N</strong>. While numbering is somewhat impersonal, it quickly becomes infeasible to name each hawk individually when
|
4 |
+
you have as many hawks as Mr. Fox.
|
5 |
+
</p>
|
6 |
+
|
7 |
+
<p>
|
8 |
+
Every year, the local falconer club hosts a festival for falconers from across the nation. Mr. Fox shows off some of his hawks at each festival,
|
9 |
+
and this year is no different. Selecting a set of hawks to display is not a straightforward task however. Hawks can be temperamental creatures,
|
10 |
+
and they'll refuse to perform if they don't like the situation they find themselves in. Luckily, after careful study, Mr. Fox has been able to
|
11 |
+
capture the hawks' preferences in a simple boolean expression.
|
12 |
+
</p>
|
13 |
+
|
14 |
+
<p>
|
15 |
+
For example, let's say Mr. Fox has 4 hawks. Hawk 1 will only perform if some other hawk is present. Hawks 2 and 3 will only perform if hawks
|
16 |
+
1 or 4 are present. Hawk 4 is much more easy-going and will perform in all situations. We can express these preferences with the following
|
17 |
+
expression:
|
18 |
+
|
19 |
+
<pre>
|
20 |
+
((1 & (2 | 3)) | 4)
|
21 |
+
</pre>
|
22 |
+
</p>
|
23 |
+
|
24 |
+
<p>
|
25 |
+
Each number is a boolean variable indicating whether or not Mr. Fox brings that hawk. If the expression is satisfied, then all of the hawks he
|
26 |
+
brings will perform. If the expression is not satisfied, the hawks will be moody and that means no blue ribbons for Mr. Fox.
|
27 |
+
</p>
|
28 |
+
|
29 |
+
<p>
|
30 |
+
Mr. Fox is keen not to bore his audience, so he always brings a different set of hawks each year.
|
31 |
+
|
32 |
+
This is the <strong>K</strong>th annual festival, so he would like to bring the set of performing hawks with the <strong>K</strong>th
|
33 |
+
lowest value. Mr. Fox defines the value of a set of hawks as follows:
|
34 |
+
the empty set has a value of 0, and hawk <strong>i</strong> adds 2<sup><strong>i</strong></sup> to the value of a set.
|
35 |
+
|
36 |
+
So with 3 hawks, the sets in increasing order are:
|
37 |
+
|
38 |
+
<pre>
|
39 |
+
{1}
|
40 |
+
{2}
|
41 |
+
{1, 2}
|
42 |
+
{3}
|
43 |
+
{1, 3}
|
44 |
+
{2, 3}
|
45 |
+
{1, 2, 3}
|
46 |
+
</pre>
|
47 |
+
|
48 |
+
Note that Mr. Fox always brings a non-empty set of hawks.
|
49 |
+
</p>
|
50 |
+
|
51 |
+
|
52 |
+
<h3>Input</h3>
|
53 |
+
<p>
|
54 |
+
Input begins with an integer <strong>T</strong>, the number of festivals under consideration.
|
55 |
+
For each festival, there is first a line containing the space-separated integers <strong>N</strong> and <strong>K</strong>.
|
56 |
+
The next line contains the boolean expression encoding the hawks' preferences.
|
57 |
+
</p>
|
58 |
+
|
59 |
+
|
60 |
+
<h3>Output</h3>
|
61 |
+
<p>
|
62 |
+
For the <strong>i</strong>th festival, print a line containing "Case #<strong>i</strong>: " followed by
|
63 |
+
value of the set of hawks that Mr. Fox brings modulo 10<sup>9</sup>+7.
|
64 |
+
</p>
|
65 |
+
|
66 |
+
|
67 |
+
<h3>Constraints</h3>
|
68 |
+
<p>
|
69 |
+
1 ≤ <strong>T</strong> ≤ 20 <br />
|
70 |
+
1 ≤ <strong>N</strong> ≤ 200,000 <br />
|
71 |
+
1 ≤ <strong>K</strong> ≤ 10<sup>18</sup> <br />
|
72 |
+
Expressions contain no more than 2,500,000 characters each. <br />
|
73 |
+
It is guaranteed that there are at least <strong>K</strong> sets of performing hawks. <br />
|
74 |
+
</p>
|
75 |
+
|
76 |
+
<p>
|
77 |
+
The boolean expression adheres to the following grammar:
|
78 |
+
|
79 |
+
<pre>
|
80 |
+
[expression] ::= "(" "~" [expression] ")" | "(" [expression] [binary-operator] [expression] ")" | [variable]
|
81 |
+
[binary-operator] ::= "|" | "^" | "&"
|
82 |
+
[variable] ::= [digit] | [digit] [variable]
|
83 |
+
[digit] ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
|
84 |
+
</pre>
|
85 |
+
|
86 |
+
Each hawk appears in the boolean expression exactly once. <br />
|
87 |
+
Whitespace may appear arbitrarily in the expression (except within variables) to improve readability. <br />
|
88 |
+
</p>
|
89 |
+
|
90 |
+
<h3>Explanation of Sample</h3>
|
91 |
+
<p>
|
92 |
+
In the first and second cases, the first 4 performing sets, in order, are {1, 2}, {1, 3}, {1, 2, 3}, and {4}, with values of 6, 10, 14, and 16 respectively.
|
93 |
+
</p>
|
94 |
+
|
2015/finals/fox_hawks.in
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:56fc5974bcd713444e7a8c1ffd6c88234796e487ba059f644f022bacb7ee0cc2
|
3 |
+
size 12921762
|
2015/finals/fox_hawks.md
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Mr. Fox always puts aside some time on the weekends to practice his falconry.
|
2 |
+
Mr. Fox owns **N** hawks, numbered from 1 to **N**. While numbering is
|
3 |
+
somewhat impersonal, it quickly becomes infeasible to name each hawk
|
4 |
+
individually when you have as many hawks as Mr. Fox.
|
5 |
+
|
6 |
+
Every year, the local falconer club hosts a festival for falconers from across
|
7 |
+
the nation. Mr. Fox shows off some of his hawks at each festival, and this
|
8 |
+
year is no different. Selecting a set of hawks to display is not a
|
9 |
+
straightforward task however. Hawks can be temperamental creatures, and
|
10 |
+
they'll refuse to perform if they don't like the situation they find
|
11 |
+
themselves in. Luckily, after careful study, Mr. Fox has been able to capture
|
12 |
+
the hawks' preferences in a simple boolean expression.
|
13 |
+
|
14 |
+
For example, let's say Mr. Fox has 4 hawks. Hawk 1 will only perform if some
|
15 |
+
other hawk is present. Hawks 2 and 3 will only perform if hawks 1 or 4 are
|
16 |
+
present. Hawk 4 is much more easy-going and will perform in all situations. We
|
17 |
+
can express these preferences with the following expression:
|
18 |
+
|
19 |
+
((1 & (2 | 3)) | 4)
|
20 |
+
|
21 |
+
Each number is a boolean variable indicating whether or not Mr. Fox brings
|
22 |
+
that hawk. If the expression is satisfied, then all of the hawks he brings
|
23 |
+
will perform. If the expression is not satisfied, the hawks will be moody and
|
24 |
+
that means no blue ribbons for Mr. Fox.
|
25 |
+
|
26 |
+
Mr. Fox is keen not to bore his audience, so he always brings a different set
|
27 |
+
of hawks each year. This is the **K**th annual festival, so he would like to
|
28 |
+
bring the set of performing hawks with the **K**th lowest value. Mr. Fox
|
29 |
+
defines the value of a set of hawks as follows: the empty set has a value of
|
30 |
+
0, and hawk **i** adds 2**i** to the value of a set. So with 3 hawks, the sets
|
31 |
+
in increasing order are:
|
32 |
+
|
33 |
+
{1}
|
34 |
+
{2}
|
35 |
+
{1, 2}
|
36 |
+
{3}
|
37 |
+
{1, 3}
|
38 |
+
{2, 3}
|
39 |
+
{1, 2, 3}
|
40 |
+
|
41 |
+
Note that Mr. Fox always brings a non-empty set of hawks.
|
42 |
+
|
43 |
+
### Input
|
44 |
+
|
45 |
+
Input begins with an integer **T**, the number of festivals under
|
46 |
+
consideration. For each festival, there is first a line containing the space-
|
47 |
+
separated integers **N** and **K**. The next line contains the boolean
|
48 |
+
expression encoding the hawks' preferences.
|
49 |
+
|
50 |
+
### Output
|
51 |
+
|
52 |
+
For the **i**th festival, print a line containing "Case #**i**: " followed by
|
53 |
+
value of the set of hawks that Mr. Fox brings modulo 109+7.
|
54 |
+
|
55 |
+
### Constraints
|
56 |
+
|
57 |
+
1 ≤ **T** ≤ 20
|
58 |
+
1 ≤ **N** ≤ 200,000
|
59 |
+
1 ≤ **K** ≤ 1018
|
60 |
+
Expressions contain no more than 2,500,000 characters each.
|
61 |
+
It is guaranteed that there are at least **K** sets of performing hawks.
|
62 |
+
|
63 |
+
The boolean expression adheres to the following grammar:
|
64 |
+
|
65 |
+
[expression] ::= "(" "~" [expression] ")" | "(" [expression] [binary-operator] [expression] ")" | [variable]
|
66 |
+
[binary-operator] ::= "|" | "^" | "&"
|
67 |
+
[variable] ::= [digit] | [digit] [variable]
|
68 |
+
[digit] ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
|
69 |
+
|
70 |
+
Each hawk appears in the boolean expression exactly once.
|
71 |
+
Whitespace may appear arbitrarily in the expression (except within variables)
|
72 |
+
to improve readability.
|
73 |
+
|
74 |
+
### Explanation of Sample
|
75 |
+
|
76 |
+
In the first and second cases, the first 4 performing sets, in order, are {1,
|
77 |
+
2}, {1, 3}, {1, 2, 3}, and {4}, with values of 6, 10, 14, and 16 respectively.
|
78 |
+
|
2015/finals/fox_hawks.out
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Case #1: 6
|
2 |
+
Case #2: 14
|
3 |
+
Case #3: 4
|
4 |
+
Case #4: 2
|
5 |
+
Case #5: 508
|
6 |
+
Case #6: 2
|
7 |
+
Case #7: 6
|
8 |
+
Case #8: 510
|
9 |
+
Case #9: 26
|
10 |
+
Case #10: 98
|
11 |
+
Case #11: 878266293
|
12 |
+
Case #12: 746859548
|
13 |
+
Case #13: 7038259
|
14 |
+
Case #14: 454681413
|
15 |
+
Case #15: 138253392
|
16 |
+
Case #16: 299215939
|
17 |
+
Case #17: 646605572
|
18 |
+
Case #18: 783424637
|
19 |
+
Case #19: 873419939
|
20 |
+
Case #20: 959061046
|
2015/finals/fox_lochs.html
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p>
|
2 |
+
Mr. Fox is going on a trip to Scotland to witness its many beautiful lochs! He's heard that skimboarding
|
3 |
+
is a fun pastime, somewhat similar to surfing, and he'd like to give it a try while he's there.
|
4 |
+
</p>
|
5 |
+
|
6 |
+
<p>
|
7 |
+
He soon finds himself on a flat beach by the side of a loch. The beach can be represented by an infinite 2D plane,
|
8 |
+
with <strong>N</strong> axis-aligned rectangular pools of shallow water on it.
|
9 |
+
The <strong>i</strong>th pool has a pair of opposite corners at coordinates
|
10 |
+
(<strong>x<sub>1</sub></strong>, <strong>y<sub>1</sub></strong>) and
|
11 |
+
(<strong>x<sub>2</sub></strong>, <strong>y<sub>2</sub></strong>).
|
12 |
+
All of the pools can arbitrarily overlap with one another, the result being that there's shallow water everywhere within
|
13 |
+
the union of the pools' rectangles (including right on its edges), and no water anywhere else
|
14 |
+
(Mr. Fox isn't brave enough to venture into the loch itself yet!).
|
15 |
+
</p>
|
16 |
+
|
17 |
+
<p>
|
18 |
+
Mr. Fox would like to get a running start and then launch himself across the water at some location, skimboarding across
|
19 |
+
the pools in a straight line until he hits a point with no water. In other words, his skimboarding debut will consist of a
|
20 |
+
line segment contained within the union of the pools' rectangles (inclusive of borders).
|
21 |
+
What's the maximum length this line segment can have?
|
22 |
+
</p>
|
23 |
+
|
24 |
+
|
25 |
+
<h3>Input</h3>
|
26 |
+
<p>
|
27 |
+
Input begins with an integer <strong>T</strong>, the number of places Mr. Fox goes skimboarding.
|
28 |
+
For each place, there is first a line containing the integer <strong>N</strong>.
|
29 |
+
Then <strong>N</strong> lines follow, the <strong>i</strong>th of which contains the space-separated integers
|
30 |
+
<strong>x<sub>1</sub></strong>, <strong>y<sub>1</sub></strong>,
|
31 |
+
<strong>x<sub>2</sub></strong>, and <strong>y<sub>2</sub></strong>.
|
32 |
+
</p>
|
33 |
+
|
34 |
+
<h3>Output</h3>
|
35 |
+
<p>
|
36 |
+
For the <strong>i</strong>th place, print a line containing "Case #<strong>i</strong>: " followed by
|
37 |
+
the length of longest possible skimboarding path rounded to 6 decimal places.
|
38 |
+
</p>
|
39 |
+
|
40 |
+
<p>
|
41 |
+
Absolute errors of up to 2e-6 will be ignored.
|
42 |
+
</p>
|
43 |
+
|
44 |
+
|
45 |
+
<h3>Constraints</h3>
|
46 |
+
<p>
|
47 |
+
1 ≤ <strong>T</strong> ≤ 20 <br />
|
48 |
+
1 ≤ <strong>N</strong> ≤ 20 <br />
|
49 |
+
-1,000,000 ≤ <strong>x<sub>1</sub></strong> < <strong>x<sub>2</sub></strong> ≤ 1,000,000 <br />
|
50 |
+
-1,000,000 ≤ <strong>y<sub>1</sub></strong> < <strong>y<sub>2</sub></strong> ≤ 1,000,000 <br />
|
51 |
+
</p>
|
52 |
+
|
53 |
+
<h3>Explanation of Sample</h3>
|
54 |
+
<p>
|
55 |
+
In the first case, (2, 0) to (5, 5) is an optimal path.
|
56 |
+
</p>
|
57 |
+
|
2015/finals/fox_lochs.in
ADDED
@@ -0,0 +1,281 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
20
|
2 |
+
2
|
3 |
+
2 0 4 3
|
4 |
+
3 2 5 5
|
5 |
+
1
|
6 |
+
0 0 3 4
|
7 |
+
3
|
8 |
+
0 0 3 2
|
9 |
+
0 1 3 3
|
10 |
+
0 2 3 4
|
11 |
+
3
|
12 |
+
0 0 1 1
|
13 |
+
2 0 4 2
|
14 |
+
5 0 8 3
|
15 |
+
3
|
16 |
+
-3 -3 3 3
|
17 |
+
-2 -2 2 2
|
18 |
+
-1 -1 1 1
|
19 |
+
2
|
20 |
+
0 0 3 7
|
21 |
+
0 0 6 3
|
22 |
+
3
|
23 |
+
0 0 1 1
|
24 |
+
1 1 2 2
|
25 |
+
2 2 3 3
|
26 |
+
3
|
27 |
+
0 0 1 5
|
28 |
+
1 5 2 10
|
29 |
+
0 10 1 15
|
30 |
+
20
|
31 |
+
-286959 -309830 334986 310737
|
32 |
+
33558 -723747 52007 -389359
|
33 |
+
-268327 -620833 82947 -478539
|
34 |
+
-152349 -646539 -4651 -257395
|
35 |
+
-503006 -723965 -401305 -650415
|
36 |
+
151877 90069 803553 170528
|
37 |
+
-111556 74872 395038 200804
|
38 |
+
-642206 -690890 -485591 -630053
|
39 |
+
-858953 -421459 -788731 -165102
|
40 |
+
-392378 -786805 156551 -591853
|
41 |
+
-383323 -501911 180233 107362
|
42 |
+
-454245 -457792 -434302 -24990
|
43 |
+
-148004 -843252 97841 -468546
|
44 |
+
-701841 -388101 -195752 -273116
|
45 |
+
-559696 -394542 -317264 283349
|
46 |
+
118386 -157347 302171 142939
|
47 |
+
-739140 -571503 -103371 -221701
|
48 |
+
-838348 -67776 -576656 -19
|
49 |
+
-205798 -548617 323327 -119097
|
50 |
+
-315029 -201609 45362 474272
|
51 |
+
20
|
52 |
+
-56698 -76497 229042 -49564
|
53 |
+
-468342 74546 -358948 237252
|
54 |
+
7070 -242470 140836 -214080
|
55 |
+
-166709 98233 -143885 178953
|
56 |
+
-474396 -147112 -443646 -70639
|
57 |
+
65062 -466898 386507 -435564
|
58 |
+
-325446 -371266 8155 -339461
|
59 |
+
-145641 86478 33245 417712
|
60 |
+
1412 58495 265795 325852
|
61 |
+
-200837 -387826 95655 -126137
|
62 |
+
-349463 -478682 -250910 -365103
|
63 |
+
-376558 -301409 -330534 4060
|
64 |
+
-340910 -24425 -336269 79805
|
65 |
+
-342914 85227 -198322 386595
|
66 |
+
-162775 -74349 83589 -25287
|
67 |
+
-491645 -453352 -185269 -156616
|
68 |
+
-217061 -484110 13086 -476098
|
69 |
+
-351803 -20542 -201697 187589
|
70 |
+
-172586 -338264 53442 -197491
|
71 |
+
-110964 -341694 209002 -120068
|
72 |
+
20
|
73 |
+
-9072 -248220 83415 -203481
|
74 |
+
-170983 -316985 16689 -267759
|
75 |
+
-171040 -139842 -144962 -26127
|
76 |
+
-268542 28784 -167429 144428
|
77 |
+
-271051 66459 -161643 106674
|
78 |
+
-324382 33354 -251785 94597
|
79 |
+
-106430 -83021 82658 30957
|
80 |
+
35223 -329483 248486 -99458
|
81 |
+
-35622 -114816 49117 118263
|
82 |
+
-332013 -2285 -176099 218858
|
83 |
+
-122000 -184394 -78831 -35414
|
84 |
+
-134236 -80732 37417 -53269
|
85 |
+
-324531 -22448 -228942 191073
|
86 |
+
-216533 -223571 -96868 -38054
|
87 |
+
-289292 -35608 -191713 41863
|
88 |
+
-196386 -300406 -59213 -225864
|
89 |
+
-113985 4446 108796 210785
|
90 |
+
13025 -232421 161903 -75201
|
91 |
+
-71335 4779 -58763 73465
|
92 |
+
36680 -232827 136759 -99643
|
93 |
+
20
|
94 |
+
5579 -246611 32830 -113542
|
95 |
+
-93905 -232057 -39380 -199416
|
96 |
+
-154243 25712 -17335 102898
|
97 |
+
-249508 -24333 -167958 49577
|
98 |
+
-135636 -231069 -89903 -131140
|
99 |
+
-191417 -94448 -87629 -71937
|
100 |
+
10274 -197755 89917 -87210
|
101 |
+
14739 -209727 168254 -96253
|
102 |
+
-228532 -115472 -202255 39421
|
103 |
+
-197083 -47195 -116247 24234
|
104 |
+
25944 -78346 34459 -71634
|
105 |
+
-202746 -122860 -150961 -55443
|
106 |
+
-204969 -129370 -73072 34399
|
107 |
+
13023 -138975 75333 -69086
|
108 |
+
7099 40102 11815 183412
|
109 |
+
-241157 -8200 -103580 -2399
|
110 |
+
-84614 -15688 72061 158538
|
111 |
+
-52888 -19329 -3013 85879
|
112 |
+
-208920 -23497 -94905 63983
|
113 |
+
-205259 10742 -138022 156670
|
114 |
+
20
|
115 |
+
-147440 -178232 -29838 -157769
|
116 |
+
-192795 -193111 -179992 -64460
|
117 |
+
-52052 25852 -35729 73137
|
118 |
+
-189013 -83926 -144121 27031
|
119 |
+
-167256 -76822 -65383 1552
|
120 |
+
-102965 -97543 10034 -84305
|
121 |
+
-190814 -160649 -123915 -24620
|
122 |
+
20799 -58018 61773 -21843
|
123 |
+
-80004 35359 -18846 145438
|
124 |
+
-51745 -20134 33773 45507
|
125 |
+
-13672 -35014 85518 47094
|
126 |
+
-103513 -27412 -96996 -6257
|
127 |
+
-87270 -13638 24988 50441
|
128 |
+
-137356 -162232 -107018 -160117
|
129 |
+
-1878 -167191 14278 -44636
|
130 |
+
-50105 -41441 35376 69976
|
131 |
+
-105041 -45907 4214 51770
|
132 |
+
-160512 17115 -110644 26204
|
133 |
+
-190316 -163258 -159765 -45180
|
134 |
+
-170333 -94239 -54171 8352
|
135 |
+
20
|
136 |
+
-17455 -74758 36301 8458
|
137 |
+
-116932 -29616 -86407 -14124
|
138 |
+
-102390 -105717 -36616 -92015
|
139 |
+
-46311 -80330 25809 -1681
|
140 |
+
-59512 -3365 -28955 79789
|
141 |
+
-159133 -53948 -94500 -48983
|
142 |
+
-7897 -11787 27456 67079
|
143 |
+
7640 -159791 57214 -109531
|
144 |
+
-104552 -138433 -101879 -47182
|
145 |
+
-129159 -80554 -18336 -37052
|
146 |
+
10858 -110133 23607 -3947
|
147 |
+
-70012 -49126 -21294 -1865
|
148 |
+
-136528 31026 -78300 41005
|
149 |
+
-29498 -969 -3260 54784
|
150 |
+
-14159 -149687 38880 -133605
|
151 |
+
-70323 15009 14200 45372
|
152 |
+
-113458 -55704 -112510 -24565
|
153 |
+
23826 -11480 46306 41872
|
154 |
+
-40612 -91079 59178 5869
|
155 |
+
-15838 -166587 -8220 -164587
|
156 |
+
20
|
157 |
+
-17572 -53841 -181 3051
|
158 |
+
-20709 -131747 -8694 -88323
|
159 |
+
-22701 9893 43653 77685
|
160 |
+
-126897 24627 -109680 57123
|
161 |
+
-103003 -49152 -23091 -25020
|
162 |
+
-84271 -88731 15354 -81316
|
163 |
+
-24434 -108880 3060 -19269
|
164 |
+
-55147 -40417 -14478 -22457
|
165 |
+
-64899 -127179 -59272 -114018
|
166 |
+
-102804 -110689 -72485 -94457
|
167 |
+
-7751 2228 1307 65397
|
168 |
+
24055 19982 52083 51941
|
169 |
+
-8345 -27087 5629 282
|
170 |
+
-83445 -116242 -58723 -75591
|
171 |
+
-48987 -94471 -19733 -52461
|
172 |
+
-22666 -142121 40579 -50429
|
173 |
+
-98752 -93233 -86806 -76446
|
174 |
+
-55080 -111344 -29543 -100929
|
175 |
+
-17838 -50404 65601 -12087
|
176 |
+
-95013 -23764 -46180 29085
|
177 |
+
20
|
178 |
+
-87550 -101178 -51779 -99855
|
179 |
+
-9766 -38636 41757 -11166
|
180 |
+
22762 -65842 73389 -18143
|
181 |
+
-23117 1473 -5446 60301
|
182 |
+
-8146 -30366 6864 -21041
|
183 |
+
-7616 11491 48692 76162
|
184 |
+
-53000 -34734 -20977 19735
|
185 |
+
-3691 -88225 11252 -6150
|
186 |
+
-19468 12823 13191 40608
|
187 |
+
-59210 13809 16067 18458
|
188 |
+
-99759 -58683 -18285 -8418
|
189 |
+
-82595 5044 -79233 13699
|
190 |
+
-124017 -32968 -55394 -22893
|
191 |
+
16418 -89047 47872 -55673
|
192 |
+
-79007 -65672 -71587 -54575
|
193 |
+
-111743 19148 -69193 19263
|
194 |
+
-103893 -21530 -18622 37169
|
195 |
+
21799 -120029 87722 -117247
|
196 |
+
-74348 -38929 -19163 12163
|
197 |
+
17077 -50400 77264 30331
|
198 |
+
20
|
199 |
+
-56640 -8303 15376 62896
|
200 |
+
-27746 -86147 -2573 -8422
|
201 |
+
-63624 -69749 -15681 -24768
|
202 |
+
7611 -68224 79058 -47319
|
203 |
+
-32360 -27295 -1703 -2166
|
204 |
+
6527 -4517 70622 1355
|
205 |
+
5124 -14917 17478 59963
|
206 |
+
2290 6420 29184 77225
|
207 |
+
-2998 -81277 34722 -42463
|
208 |
+
1197 -65052 42889 -5195
|
209 |
+
16031 -109329 37529 -66346
|
210 |
+
6022 -102492 61782 -72763
|
211 |
+
7297 -75249 74658 -7980
|
212 |
+
16290 -28199 47092 46586
|
213 |
+
-53286 -95120 -35670 -35681
|
214 |
+
-10628 3751 36173 14712
|
215 |
+
12704 -7833 69424 37141
|
216 |
+
-44089 -88604 -10643 -73802
|
217 |
+
9538 -102748 85961 -80402
|
218 |
+
-9780 -29025 64016 -3570
|
219 |
+
20
|
220 |
+
-48533 -8968 -22352 46291
|
221 |
+
-88263 -62589 -45656 -60097
|
222 |
+
-54735 1230 -6907 14679
|
223 |
+
-56687 6797 -20806 50977
|
224 |
+
-2399 -89810 47880 -20712
|
225 |
+
-1648 -89075 37023 -48638
|
226 |
+
-98627 -6831 -96537 27407
|
227 |
+
-685 -48031 53809 2301
|
228 |
+
-70452 -38969 -42920 -35580
|
229 |
+
-82666 -55649 -37460 -4001
|
230 |
+
-72750 -92869 -59839 -59464
|
231 |
+
2873 4631 72004 52745
|
232 |
+
2393 9971 48670 64638
|
233 |
+
-24002 -70573 -22003 -25585
|
234 |
+
-61524 -82097 -38016 -46947
|
235 |
+
-23737 13271 40241 38043
|
236 |
+
-76971 -43961 -55528 6815
|
237 |
+
-65252 -93 -20706 26810
|
238 |
+
-64026 8111 -26672 26101
|
239 |
+
13923 -79634 74725 -71378
|
240 |
+
20
|
241 |
+
-76912 -48008 -65471 -26195
|
242 |
+
-74401 -71091 -40758 -15699
|
243 |
+
-86942 -749 -66637 45740
|
244 |
+
-72617 -33078 -27480 -30641
|
245 |
+
911 -12941 1636 39602
|
246 |
+
-87746 -45994 -37784 11359
|
247 |
+
-85385 -7190 -39515 -1582
|
248 |
+
-51334 -54155 -20347 -478
|
249 |
+
-35514 -62145 -18819 -12539
|
250 |
+
-29588 14631 -23940 68827
|
251 |
+
-9643 -55660 -3198 -20861
|
252 |
+
-38674 -13854 -18982 15986
|
253 |
+
-28253 4686 -17157 51408
|
254 |
+
-65274 13567 -41888 59376
|
255 |
+
-6352 -23950 37207 98
|
256 |
+
-44782 -77533 -40738 -76307
|
257 |
+
-4536 -67308 26807 -61508
|
258 |
+
14894 -84834 40902 -79828
|
259 |
+
3434 -26027 50346 -15738
|
260 |
+
-13336 -76227 -7978 -31627
|
261 |
+
20
|
262 |
+
-27361 -74150 -7367 -53554
|
263 |
+
-3283 -79619 36724 -73508
|
264 |
+
-34876 -8866 -25718 33301
|
265 |
+
-64304 -57439 -14760 -11866
|
266 |
+
-21065 -14369 -10867 42597
|
267 |
+
-70002 -28140 -67632 -26453
|
268 |
+
-70686 -27308 -52392 -6214
|
269 |
+
11979 -78639 39735 -44027
|
270 |
+
-30308 2134 9087 21944
|
271 |
+
-17073 -1104 38844 21617
|
272 |
+
-22661 9895 -19355 53076
|
273 |
+
-58070 -5105 -41902 -2664
|
274 |
+
-6487 -4027 8257 33446
|
275 |
+
-22206 -30805 878 -5010
|
276 |
+
-30766 -36212 -3548 -29303
|
277 |
+
-51240 -44079 3373 -24353
|
278 |
+
-33817 -76274 -18268 -54160
|
279 |
+
-37690 -29943 -4121 970
|
280 |
+
-44221 -53656 4794 -19338
|
281 |
+
-689 -26180 4766 28372
|
2015/finals/fox_lochs.md
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Mr. Fox is going on a trip to Scotland to witness its many beautiful lochs!
|
2 |
+
He's heard that skimboarding is a fun pastime, somewhat similar to surfing,
|
3 |
+
and he'd like to give it a try while he's there.
|
4 |
+
|
5 |
+
He soon finds himself on a flat beach by the side of a loch. The beach can be
|
6 |
+
represented by an infinite 2D plane, with **N** axis-aligned rectangular pools
|
7 |
+
of shallow water on it. The **i**th pool has a pair of opposite corners at
|
8 |
+
coordinates (**x1**, **y1**) and (**x2**, **y2**). All of the pools can
|
9 |
+
arbitrarily overlap with one another, the result being that there's shallow
|
10 |
+
water everywhere within the union of the pools' rectangles (including right on
|
11 |
+
its edges), and no water anywhere else (Mr. Fox isn't brave enough to venture
|
12 |
+
into the loch itself yet!).
|
13 |
+
|
14 |
+
Mr. Fox would like to get a running start and then launch himself across the
|
15 |
+
water at some location, skimboarding across the pools in a straight line until
|
16 |
+
he hits a point with no water. In other words, his skimboarding debut will
|
17 |
+
consist of a line segment contained within the union of the pools' rectangles
|
18 |
+
(inclusive of borders). What's the maximum length this line segment can have?
|
19 |
+
|
20 |
+
### Input
|
21 |
+
|
22 |
+
Input begins with an integer **T**, the number of places Mr. Fox goes
|
23 |
+
skimboarding. For each place, there is first a line containing the integer
|
24 |
+
**N**. Then **N** lines follow, the **i**th of which contains the space-
|
25 |
+
separated integers **x1**, **y1**, **x2**, and **y2**.
|
26 |
+
|
27 |
+
### Output
|
28 |
+
|
29 |
+
For the **i**th place, print a line containing "Case #**i**: " followed by the
|
30 |
+
length of longest possible skimboarding path rounded to 6 decimal places.
|
31 |
+
|
32 |
+
Absolute errors of up to 2e-6 will be ignored.
|
33 |
+
|
34 |
+
### Constraints
|
35 |
+
|
36 |
+
1 ≤ **T** ≤ 20
|
37 |
+
1 ≤ **N** ≤ 20
|
38 |
+
-1,000,000 ≤ **x1** < **x2** ≤ 1,000,000
|
39 |
+
-1,000,000 ≤ **y1** < **y2** ≤ 1,000,000
|
40 |
+
|
41 |
+
### Explanation of Sample
|
42 |
+
|
43 |
+
In the first case, (2, 0) to (5, 5) is an optimal path.
|
44 |
+
|
2015/finals/fox_lochs.out
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Case #1: 5.830952
|
2 |
+
Case #2: 5.000000
|
3 |
+
Case #3: 5.000000
|
4 |
+
Case #4: 4.242641
|
5 |
+
Case #5: 8.485281
|
6 |
+
Case #6: 8.750000
|
7 |
+
Case #7: 4.242641
|
8 |
+
Case #8: 15.000000
|
9 |
+
Case #9: 1439133.979724
|
10 |
+
Case #10: 884005.747931
|
11 |
+
Case #11: 650595.679101
|
12 |
+
Case #12: 406740.250958
|
13 |
+
Case #13: 375892.303625
|
14 |
+
Case #14: 261653.376275
|
15 |
+
Case #15: 223308.221962
|
16 |
+
Case #16: 200551.423396
|
17 |
+
Case #17: 214887.140352
|
18 |
+
Case #18: 172942.536512
|
19 |
+
Case #19: 131482.402853
|
20 |
+
Case #20: 129424.576294
|
2015/finals/fox_locks.html
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p>
|
2 |
+
Mr. Fox has just won the lottery! As a result, he's treated himself to some gifts —
|
3 |
+
a few socks, a few rocks, a few blocks... oh, and the entire Panama canal system.
|
4 |
+
</p>
|
5 |
+
|
6 |
+
<p>
|
7 |
+
The system has <strong>K</strong> canals, the <strong>i</strong>th of which consists of a line of
|
8 |
+
<strong>N<sub>i</sub></strong> equally-sized sections. The <strong>j</strong>th section of the <strong>i</strong>th canal
|
9 |
+
initially contains <strong>W<sub>i,j</sub></strong> gallons of water. There's also an initially closed lock (a retractable wall) between
|
10 |
+
each pair of adjacent sections (that is, between sections 1 and 2, sections 2 and 3, and so on).
|
11 |
+
As such, there are <strong>N<sub>i</sub></strong>-1 such locks in the <strong>i</strong>th canal.
|
12 |
+
</p>
|
13 |
+
|
14 |
+
<p>
|
15 |
+
The canals are all linked to each other by an additional central hub section (also of equal size to the other sections),
|
16 |
+
which initially contains <strong>H</strong> gallons of water. This section is adjacent to the 1st section of each of the canals,
|
17 |
+
separated by a special initially closed lock. As such, there are <strong>K</strong> such central locks.
|
18 |
+
</p>
|
19 |
+
|
20 |
+
<p>
|
21 |
+
Mr. Fox is relaxing in a yacht (oh, right, he also bought himself one of those) floating in the central hub section.
|
22 |
+
Just for fun, he'd like to raise the water level in this section as high as possible. To do so, he may give any (potentially empty) sequence
|
23 |
+
of commands to his Panama employees, one per minute. Each command consists of selecting a single lock anywhere in the canal system
|
24 |
+
and toggling it from being closed to being open (or vice versa). In the following minute, the water will level out (as water tends to do) by
|
25 |
+
flowing through open locks such that, for any pair of adjacent sections which are separated by an open lock, they will end up with equal
|
26 |
+
amounts of water. Mr. Fox does need to obey the Panama canal system's safety regulations, however, which impose one restriction on his
|
27 |
+
commands: whenever one of the <strong>K</strong> central locks adjacent to the central hub section is opened, it must be closed a
|
28 |
+
minute later and then never re-opened.
|
29 |
+
</p>
|
30 |
+
|
31 |
+
<p>
|
32 |
+
Mr. Fox loves watching water flow through his locks, especially when it allows his yacht to magically rise up. Wheeeee! By commanding his employees carefully, how much water can Mr. Fox get into the central hub section?
|
33 |
+
</p>
|
34 |
+
|
35 |
+
|
36 |
+
<h3>Constraints</h3>
|
37 |
+
<p>
|
38 |
+
1 ≤ <strong>T</strong> ≤ 20 <br/>
|
39 |
+
1 ≤ <strong>K</strong> ≤ 50 <br/>
|
40 |
+
0 ≤ <strong>H</strong> ≤ 10^9 <br/>
|
41 |
+
1 ≤ <strong>N<sub>i</sub></strong> ≤ 100,000 <br/>
|
42 |
+
<strong>N<sub>i</sub></strong> > 1 implies
|
43 |
+
<strong>N<sub>i+1</sub></strong> ≥ 2*<strong>N<sub>i</sub></strong>
|
44 |
+
(for 1 ≤ <strong>i</strong> < <strong>K</strong>) <br/>
|
45 |
+
0 ≤ <strong>W<sub>i,j</sub></strong> ≤ 10^9 <br/>
|
46 |
+
</p>
|
47 |
+
|
48 |
+
|
49 |
+
<h3>Input</h3>
|
50 |
+
<p>
|
51 |
+
Input begins with an integer <strong>T</strong>, the number of canal systems Mr. Fox owns.
|
52 |
+
For each system, there is first a line containing the space-separated integers <strong>K</strong> and <strong>H</strong>.
|
53 |
+
Then, <strong>K</strong> lines follow, the <strong>i</strong>th of which contains the integer <strong>N<sub>i</sub></strong>
|
54 |
+
followed by the space-separated integers <strong>W<sub>i,1</sub></strong> ... <strong>W<sub>i,N<sub>i</sub></sub></strong>.
|
55 |
+
</p>
|
56 |
+
|
57 |
+
|
58 |
+
<h3>Output</h3>
|
59 |
+
<p>
|
60 |
+
For the <strong>i</strong>th canal system, print a line containing "Case #<strong>i</strong>: " followed by
|
61 |
+
the maximum amount of water (in gallons) that can end up in the central hub section, rounded to 6 decimal places.
|
62 |
+
</p>
|
63 |
+
|
64 |
+
<p>
|
65 |
+
Absolute errors of up to 5e-6 will be ignored.
|
66 |
+
</p>
|
67 |
+
|
68 |
+
|
69 |
+
<h3>Explanation of Sample</h3>
|
70 |
+
<p>
|
71 |
+
In the first case, the optimal solution is to first open and close the lock between the central hub and canal 1.
|
72 |
+
This leaves the central hub with 0.5 gallons of water. Then, opening the lock between the central hub and canal 2 leaves the central hub
|
73 |
+
with 1.25 gallons of water.
|
74 |
+
</p>
|
2015/finals/fox_locks.in
ADDED
The diff for this file is too large to render.
See raw diff
|
|
2015/finals/fox_locks.md
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Mr. Fox has just won the lottery! As a result, he's treated himself to some
|
2 |
+
gifts — a few socks, a few rocks, a few blocks... oh, and the entire Panama
|
3 |
+
canal system.
|
4 |
+
|
5 |
+
The system has **K** canals, the **i**th of which consists of a line of **Ni**
|
6 |
+
equally-sized sections. The **j**th section of the **i**th canal initially
|
7 |
+
contains **Wi,j** gallons of water. There's also an initially closed lock (a
|
8 |
+
retractable wall) between each pair of adjacent sections (that is, between
|
9 |
+
sections 1 and 2, sections 2 and 3, and so on). As such, there are **Ni**-1
|
10 |
+
such locks in the **i**th canal.
|
11 |
+
|
12 |
+
The canals are all linked to each other by an additional central hub section
|
13 |
+
(also of equal size to the other sections), which initially contains **H**
|
14 |
+
gallons of water. This section is adjacent to the 1st section of each of the
|
15 |
+
canals, separated by a special initially closed lock. As such, there are **K**
|
16 |
+
such central locks.
|
17 |
+
|
18 |
+
Mr. Fox is relaxing in a yacht (oh, right, he also bought himself one of
|
19 |
+
those) floating in the central hub section. Just for fun, he'd like to raise
|
20 |
+
the water level in this section as high as possible. To do so, he may give any
|
21 |
+
(potentially empty) sequence of commands to his Panama employees, one per
|
22 |
+
minute. Each command consists of selecting a single lock anywhere in the canal
|
23 |
+
system and toggling it from being closed to being open (or vice versa). In the
|
24 |
+
following minute, the water will level out (as water tends to do) by flowing
|
25 |
+
through open locks such that, for any pair of adjacent sections which are
|
26 |
+
separated by an open lock, they will end up with equal amounts of water. Mr.
|
27 |
+
Fox does need to obey the Panama canal system's safety regulations, however,
|
28 |
+
which impose one restriction on his commands: whenever one of the **K**
|
29 |
+
central locks adjacent to the central hub section is opened, it must be closed
|
30 |
+
a minute later and then never re-opened.
|
31 |
+
|
32 |
+
Mr. Fox loves watching water flow through his locks, especially when it allows
|
33 |
+
his yacht to magically rise up. Wheeeee! By commanding his employees
|
34 |
+
carefully, how much water can Mr. Fox get into the central hub section?
|
35 |
+
|
36 |
+
### Constraints
|
37 |
+
|
38 |
+
1 ≤ **T** ≤ 20
|
39 |
+
1 ≤ **K** ≤ 50
|
40 |
+
0 ≤ **H** ≤ 10^9
|
41 |
+
1 ≤ **Ni** ≤ 100,000
|
42 |
+
**Ni** > 1 implies **Ni+1** ≥ 2***Ni** (for 1 ≤ **i** < **K**)
|
43 |
+
0 ≤ **Wi,j** ≤ 10^9
|
44 |
+
|
45 |
+
### Input
|
46 |
+
|
47 |
+
Input begins with an integer **T**, the number of canal systems Mr. Fox owns.
|
48 |
+
For each system, there is first a line containing the space-separated integers
|
49 |
+
**K** and **H**. Then, **K** lines follow, the **i**th of which contains the
|
50 |
+
integer **Ni** followed by the space-separated integers **Wi,1** ...
|
51 |
+
**Wi,Ni**.
|
52 |
+
|
53 |
+
### Output
|
54 |
+
|
55 |
+
For the **i**th canal system, print a line containing "Case #**i**: " followed
|
56 |
+
by the maximum amount of water (in gallons) that can end up in the central hub
|
57 |
+
section, rounded to 6 decimal places.
|
58 |
+
|
59 |
+
Absolute errors of up to 5e-6 will be ignored.
|
60 |
+
|
61 |
+
### Explanation of Sample
|
62 |
+
|
63 |
+
In the first case, the optimal solution is to first open and close the lock
|
64 |
+
between the central hub and canal 1. This leaves the central hub with 0.5
|
65 |
+
gallons of water. Then, opening the lock between the central hub and canal 2
|
66 |
+
leaves the central hub with 1.25 gallons of water.
|
67 |
+
|
2015/finals/fox_locks.out
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Case #1: 1.250000
|
2 |
+
Case #2: 7.500000
|
3 |
+
Case #3: 9.428571
|
4 |
+
Case #4: 9.100000
|
5 |
+
Case #5: 121.465278
|
6 |
+
Case #6: 7.272727
|
7 |
+
Case #7: 9.500000
|
8 |
+
Case #8: 977326399.687126
|
9 |
+
Case #9: 960513538.070536
|
10 |
+
Case #10: 933171236.379669
|
11 |
+
Case #11: 916380015.475403
|
12 |
+
Case #12: 978947197.076133
|
13 |
+
Case #13: 959541028.712926
|
14 |
+
Case #14: 939205642.630288
|
15 |
+
Case #15: 935796566.343075
|
16 |
+
Case #16: 992620512.365391
|
17 |
+
Case #17: 944841437.133588
|
18 |
+
Case #18: 978504891.417060
|
19 |
+
Case #19: 980182123.567300
|
20 |
+
Case #20: 975118031.550553
|
2015/quals/cooking_the_books.html
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p>
|
2 |
+
Every business can make use of a good accountant and, if they're not big on following the law,
|
3 |
+
sometimes a bad one.
|
4 |
+
Bad accountants try to make more money for their employers by fudging numbers
|
5 |
+
without getting caught.
|
6 |
+
</p>
|
7 |
+
|
8 |
+
<p>
|
9 |
+
Sometimes a bad accountant wants to make a number larger, and sometimes smaller.
|
10 |
+
It is widely known that tax auditors will fail to notice two digits being swapped in any given number,
|
11 |
+
but any discrepancy more egregious will certainly be caught. It's also painfully obvious when a
|
12 |
+
number has fewer digits than it ought to, so a bad accountant will never swap the first digit of a number
|
13 |
+
with a 0.
|
14 |
+
</p>
|
15 |
+
|
16 |
+
<p>
|
17 |
+
Given a number, how small or large can it be made without being found out?
|
18 |
+
</p>
|
19 |
+
|
20 |
+
|
21 |
+
<h3>Input</h3>
|
22 |
+
|
23 |
+
<p>
|
24 |
+
Input begins with an integer <strong>T</strong>, the number of numbers
|
25 |
+
that need tweaking. Each of the next <strong>T</strong> lines contains a
|
26 |
+
integer <strong>N</strong>.
|
27 |
+
</p>
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
<h3>Output</h3>
|
32 |
+
|
33 |
+
<p>
|
34 |
+
For the <em>i</em>th number, print a line containing "Case #<em>i</em>: " followed by the smallest and largest
|
35 |
+
numbers that can be made from the original number <strong>N</strong>, using at most a single swap and following the
|
36 |
+
rules above.
|
37 |
+
</p>
|
38 |
+
|
39 |
+
<h3>Constraints</h3>
|
40 |
+
|
41 |
+
<p>
|
42 |
+
1 ≤ <strong>T</strong> ≤ 100 <br />
|
43 |
+
0 ≤ <strong>N</strong> ≤ 999999999 <br />
|
44 |
+
<strong>N</strong> will never begin with a leading 0 unless <strong>N</strong> = 0<br />
|
45 |
+
</p>
|
2015/quals/cooking_the_books.in
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
100
|
2 |
+
31524
|
3 |
+
897
|
4 |
+
123
|
5 |
+
10
|
6 |
+
5
|
7 |
+
999999999
|
8 |
+
0
|
9 |
+
10
|
10 |
+
9990999
|
11 |
+
939214502
|
12 |
+
773452111
|
13 |
+
142155100
|
14 |
+
604231672
|
15 |
+
857412048
|
16 |
+
287689159
|
17 |
+
422931895
|
18 |
+
728154034
|
19 |
+
926288077
|
20 |
+
380045476
|
21 |
+
869841756
|
22 |
+
472956328
|
23 |
+
67954827
|
24 |
+
324585222
|
25 |
+
796888162
|
26 |
+
906755308
|
27 |
+
686277820
|
28 |
+
718179101
|
29 |
+
983606612
|
30 |
+
172720996
|
31 |
+
438536300
|
32 |
+
675905967
|
33 |
+
183177323
|
34 |
+
344115361
|
35 |
+
229735494
|
36 |
+
626713815
|
37 |
+
315466572
|
38 |
+
189923057
|
39 |
+
158421087
|
40 |
+
519644114
|
41 |
+
623885686
|
42 |
+
47078002
|
43 |
+
290009020
|
44 |
+
504349673
|
45 |
+
301819730
|
46 |
+
95124058
|
47 |
+
731566438
|
48 |
+
71429777
|
49 |
+
522400210
|
50 |
+
339027548
|
51 |
+
229060391
|
52 |
+
470695573
|
53 |
+
474712259
|
54 |
+
408886824
|
55 |
+
216793189
|
56 |
+
314146739
|
57 |
+
57961734
|
58 |
+
393698191
|
59 |
+
208297360
|
60 |
+
134351747
|
61 |
+
331343270
|
62 |
+
731407053
|
63 |
+
764921681
|
64 |
+
621007349
|
65 |
+
218198062
|
66 |
+
32753219
|
67 |
+
442015041
|
68 |
+
155530534
|
69 |
+
181355259
|
70 |
+
342244656
|
71 |
+
476018690
|
72 |
+
26761681
|
73 |
+
497609663
|
74 |
+
724144391
|
75 |
+
30426294
|
76 |
+
655612982
|
77 |
+
820715607
|
78 |
+
545178093
|
79 |
+
749039533
|
80 |
+
474867873
|
81 |
+
994967987
|
82 |
+
877115755
|
83 |
+
572373221
|
84 |
+
102163946
|
85 |
+
763307818
|
86 |
+
571198404
|
87 |
+
469689830
|
88 |
+
411524629
|
89 |
+
197557112
|
90 |
+
729970282
|
91 |
+
23734873
|
92 |
+
469952340
|
93 |
+
444558727
|
94 |
+
691917617
|
95 |
+
363033526
|
96 |
+
364669874
|
97 |
+
86432949
|
98 |
+
314138255
|
99 |
+
92106130
|
100 |
+
640187092
|
101 |
+
376660869
|
2015/quals/cooking_the_books.md
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Every business can make use of a good accountant and, if they're not big on
|
2 |
+
following the law, sometimes a bad one. Bad accountants try to make more money
|
3 |
+
for their employers by fudging numbers without getting caught.
|
4 |
+
|
5 |
+
Sometimes a bad accountant wants to make a number larger, and sometimes
|
6 |
+
smaller. It is widely known that tax auditors will fail to notice two digits
|
7 |
+
being swapped in any given number, but any discrepancy more egregious will
|
8 |
+
certainly be caught. It's also painfully obvious when a number has fewer
|
9 |
+
digits than it ought to, so a bad accountant will never swap the first digit
|
10 |
+
of a number with a 0.
|
11 |
+
|
12 |
+
Given a number, how small or large can it be made without being found out?
|
13 |
+
|
14 |
+
### Input
|
15 |
+
|
16 |
+
Input begins with an integer **T**, the number of numbers that need tweaking.
|
17 |
+
Each of the next **T** lines contains a integer **N**.
|
18 |
+
|
19 |
+
### Output
|
20 |
+
|
21 |
+
For the _i_th number, print a line containing "Case #_i_: " followed by the
|
22 |
+
smallest and largest numbers that can be made from the original number **N**,
|
23 |
+
using at most a single swap and following the rules above.
|
24 |
+
|
25 |
+
### Constraints
|
26 |
+
|
27 |
+
1 ≤ **T** ≤ 100
|
28 |
+
0 ≤ **N** ≤ 999999999
|
29 |
+
**N** will never begin with a leading 0 unless **N** = 0
|
30 |
+
|
2015/quals/cooking_the_books.out
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Case #1: 13524 51324
|
2 |
+
Case #2: 798 987
|
3 |
+
Case #3: 123 321
|
4 |
+
Case #4: 10 10
|
5 |
+
Case #5: 5 5
|
6 |
+
Case #6: 999999999 999999999
|
7 |
+
Case #7: 0 0
|
8 |
+
Case #8: 10 10
|
9 |
+
Case #9: 9099999 9999990
|
10 |
+
Case #10: 139294502 993214502
|
11 |
+
Case #11: 173452117 775432111
|
12 |
+
Case #12: 102155104 542151100
|
13 |
+
Case #13: 104236672 704231662
|
14 |
+
Case #14: 157482048 887412045
|
15 |
+
Case #15: 187689259 987689152
|
16 |
+
Case #16: 122934895 922931845
|
17 |
+
Case #17: 128754034 827154034
|
18 |
+
Case #18: 226988077 986282077
|
19 |
+
Case #19: 300845476 830045476
|
20 |
+
Case #20: 169848756 968841756
|
21 |
+
Case #21: 272956348 972456328
|
22 |
+
Case #22: 27954867 97654827
|
23 |
+
Case #23: 224585223 824535222
|
24 |
+
Case #24: 196888762 976888162
|
25 |
+
Case #25: 306755908 986755300
|
26 |
+
Case #26: 286277860 886277620
|
27 |
+
Case #27: 118179107 918177101
|
28 |
+
Case #28: 183606692 986606312
|
29 |
+
Case #29: 102727996 972720916
|
30 |
+
Case #30: 338536400 834536300
|
31 |
+
Case #31: 575906967 975905667
|
32 |
+
Case #32: 113877323 813177323
|
33 |
+
Case #33: 144115363 644115331
|
34 |
+
Case #34: 223795494 929735424
|
35 |
+
Case #35: 126713865 826713615
|
36 |
+
Case #36: 135466572 715466532
|
37 |
+
Case #37: 109923857 989123057
|
38 |
+
Case #38: 108421587 858421017
|
39 |
+
Case #39: 119644154 915644114
|
40 |
+
Case #40: 263885686 823885666
|
41 |
+
Case #41: 27078004 87074002
|
42 |
+
Case #42: 200009029 990002020
|
43 |
+
Case #43: 304349675 904345673
|
44 |
+
Case #44: 101839730 901813730
|
45 |
+
Case #45: 15924058 98124055
|
46 |
+
Case #46: 137566438 831566437
|
47 |
+
Case #47: 17429777 91427777
|
48 |
+
Case #48: 122400250 542200210
|
49 |
+
Case #49: 239037548 933027548
|
50 |
+
Case #50: 129060392 929060321
|
51 |
+
Case #51: 370695574 970645573
|
52 |
+
Case #52: 174742259 974712254
|
53 |
+
Case #53: 208886844 808886424
|
54 |
+
Case #54: 116793289 916793182
|
55 |
+
Case #55: 114346739 914146733
|
56 |
+
Case #56: 17965734 97561734
|
57 |
+
Case #57: 193698193 993698131
|
58 |
+
Case #58: 200297368 908227360
|
59 |
+
Case #59: 114353747 734351741
|
60 |
+
Case #60: 133343270 731343230
|
61 |
+
Case #61: 137407053 771403053
|
62 |
+
Case #62: 164921687 964721681
|
63 |
+
Case #63: 126007349 921007346
|
64 |
+
Case #64: 118298062 918128062
|
65 |
+
Case #65: 12753239 92753213
|
66 |
+
Case #66: 142015044 542014041
|
67 |
+
Case #67: 105535534 555530134
|
68 |
+
Case #68: 118355259 981355251
|
69 |
+
Case #69: 242344656 642244653
|
70 |
+
Case #70: 176048690 976018640
|
71 |
+
Case #71: 16761682 86761621
|
72 |
+
Case #72: 397609664 997604663
|
73 |
+
Case #73: 124144397 924144371
|
74 |
+
Case #74: 20426394 90426234
|
75 |
+
Case #75: 155662982 955612682
|
76 |
+
Case #76: 120785607 870715602
|
77 |
+
Case #77: 145578093 945178053
|
78 |
+
Case #78: 349039537 949037533
|
79 |
+
Case #79: 374867874 874867473
|
80 |
+
Case #80: 499967987 999967487
|
81 |
+
Case #81: 177185755 877715155
|
82 |
+
Case #82: 172373225 772353221
|
83 |
+
Case #83: 101263946 902163146
|
84 |
+
Case #84: 163307878 863307817
|
85 |
+
Case #85: 171598404 971158404
|
86 |
+
Case #86: 369689840 969684830
|
87 |
+
Case #87: 114524629 911524624
|
88 |
+
Case #88: 117557192 917557112
|
89 |
+
Case #89: 229970287 929770282
|
90 |
+
Case #90: 23334877 83734273
|
91 |
+
Case #91: 269954340 969452340
|
92 |
+
Case #92: 244558747 844554727
|
93 |
+
Case #93: 191917667 991617617
|
94 |
+
Case #94: 263033536 663033523
|
95 |
+
Case #95: 344669876 964663874
|
96 |
+
Case #96: 26438949 96432948
|
97 |
+
Case #97: 114338255 814133255
|
98 |
+
Case #98: 12106930 96102130
|
99 |
+
Case #99: 140687092 940187062
|
100 |
+
Case #100: 306667869 976660863
|
2015/quals/laser_maze.html
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p>
|
2 |
+
Standard mazes lose their mystery as one grows older. But throw in some lasers,
|
3 |
+
and suddenly you've got yourself a recipe for cross-generational appeal.
|
4 |
+
The object in any maze is to find your way from your starting point to some
|
5 |
+
goal. In a <em>Laser Maze</em> you must additionally contend with laser turrets.
|
6 |
+
</p>
|
7 |
+
|
8 |
+
<p>
|
9 |
+
A laser turret is a stationary pillar that both blocks your movement and fires
|
10 |
+
lasers from one side. Every time you take a step (either up, down, left, or right),
|
11 |
+
every laser turret in the maze then
|
12 |
+
rotates 90 degrees clockwise, and then shoots a momentary laser blast in the direction that it
|
13 |
+
is facing. Needless to say, if you find yourself in the path of one of these
|
14 |
+
lasers, you won't be around long enough to find a way out. A wall is a stationary pillar that
|
15 |
+
blocks your movement, but does not fire lasers.
|
16 |
+
</p>
|
17 |
+
|
18 |
+
<p>
|
19 |
+
Lasers are powerful, but they do not pass through walls or laser turrets.
|
20 |
+
The laser turrets respond to your movements, so you can't stand still and wait
|
21 |
+
for the turrets to turn. If you reach the goal, but are immediately shot by a
|
22 |
+
laser, your efforts will have been in vain, so make sure you reach the goal
|
23 |
+
safely.
|
24 |
+
</p>
|
25 |
+
|
26 |
+
<h3>Input</h3>
|
27 |
+
|
28 |
+
<p>
|
29 |
+
Input begins with an integer <strong>T</strong>, the number of mazes
|
30 |
+
you'll explore. For each maze, there is first a line containing two integers,
|
31 |
+
<strong>M</strong> and <strong>N</strong>, the height and width of the maze,
|
32 |
+
respectively. The next <strong>M</strong> lines contain <strong>N</strong>
|
33 |
+
characters each, describing the maze:
|
34 |
+
</p>
|
35 |
+
|
36 |
+
<p>
|
37 |
+
. (empty space) <br />
|
38 |
+
# (wall) <br />
|
39 |
+
S (starting position) <br />
|
40 |
+
G (goal) <br />
|
41 |
+
< > ^ v (laser turrets) <br />
|
42 |
+
</p>
|
43 |
+
|
44 |
+
<p>
|
45 |
+
The four symbols for laser turrets signify turrets that are initially pointing
|
46 |
+
left, right, up, or down respectively before you take your first step.
|
47 |
+
</p>
|
48 |
+
|
49 |
+
|
50 |
+
<h3>Output</h3>
|
51 |
+
|
52 |
+
<p>
|
53 |
+
For the <em>i</em>th maze, print a line containing "Case #<em>i</em>: " followed by
|
54 |
+
the smallest number of steps necessary to get to the exit without being
|
55 |
+
hit by a laser, or the string "impossible'' if there is no way to reach the
|
56 |
+
goal safely.
|
57 |
+
</p>
|
58 |
+
|
59 |
+
|
60 |
+
<h3>Constraints</h3>
|
61 |
+
<p>
|
62 |
+
1 ≤ <strong>T</strong> ≤ 100 <br />
|
63 |
+
1 ≤ <strong>M</strong>, <strong>N</strong> ≤ 100 <br />
|
64 |
+
Each maze will contain exactly one 'S' and exactly one 'G'.
|
65 |
+
</p>
|
66 |
+
|
67 |
+
|
68 |
+
|
2015/quals/laser_maze.in
ADDED
The diff for this file is too large to render.
See raw diff
|
|
2015/quals/laser_maze.md
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Standard mazes lose their mystery as one grows older. But throw in some
|
2 |
+
lasers, and suddenly you've got yourself a recipe for cross-generational
|
3 |
+
appeal. The object in any maze is to find your way from your starting point to
|
4 |
+
some goal. In a _Laser Maze_ you must additionally contend with laser turrets.
|
5 |
+
|
6 |
+
A laser turret is a stationary pillar that both blocks your movement and fires
|
7 |
+
lasers from one side. Every time you take a step (either up, down, left, or
|
8 |
+
right), every laser turret in the maze then rotates 90 degrees clockwise, and
|
9 |
+
then shoots a momentary laser blast in the direction that it is facing.
|
10 |
+
Needless to say, if you find yourself in the path of one of these lasers, you
|
11 |
+
won't be around long enough to find a way out. A wall is a stationary pillar
|
12 |
+
that blocks your movement, but does not fire lasers.
|
13 |
+
|
14 |
+
Lasers are powerful, but they do not pass through walls or laser turrets. The
|
15 |
+
laser turrets respond to your movements, so you can't stand still and wait for
|
16 |
+
the turrets to turn. If you reach the goal, but are immediately shot by a
|
17 |
+
laser, your efforts will have been in vain, so make sure you reach the goal
|
18 |
+
safely.
|
19 |
+
|
20 |
+
### Input
|
21 |
+
|
22 |
+
Input begins with an integer **T**, the number of mazes you'll explore. For
|
23 |
+
each maze, there is first a line containing two integers, **M** and **N**, the
|
24 |
+
height and width of the maze, respectively. The next **M** lines contain **N**
|
25 |
+
characters each, describing the maze:
|
26 |
+
|
27 |
+
. (empty space)
|
28 |
+
# (wall)
|
29 |
+
S (starting position)
|
30 |
+
G (goal)
|
31 |
+
< > ^ v (laser turrets)
|
32 |
+
|
33 |
+
The four symbols for laser turrets signify turrets that are initially pointing
|
34 |
+
left, right, up, or down respectively before you take your first step.
|
35 |
+
|
36 |
+
### Output
|
37 |
+
|
38 |
+
For the _i_th maze, print a line containing "Case #_i_: " followed by the
|
39 |
+
smallest number of steps necessary to get to the exit without being hit by a
|
40 |
+
laser, or the string "impossible'' if there is no way to reach the goal
|
41 |
+
safely.
|
42 |
+
|
43 |
+
### Constraints
|
44 |
+
|
45 |
+
1 ≤ **T** ≤ 100
|
46 |
+
1 ≤ **M**, **N** ≤ 100
|
47 |
+
Each maze will contain exactly one 'S' and exactly one 'G'.
|
48 |
+
|
2015/quals/laser_maze.out
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Case #1: 6
|
2 |
+
Case #2: 4
|
3 |
+
Case #3: 3
|
4 |
+
Case #4: impossible
|
5 |
+
Case #5: 8
|
6 |
+
Case #6: impossible
|
7 |
+
Case #7: 1
|
8 |
+
Case #8: impossible
|
9 |
+
Case #9: 4
|
10 |
+
Case #10: 7
|
11 |
+
Case #11: 19
|
12 |
+
Case #12: 8
|
13 |
+
Case #13: 18
|
14 |
+
Case #14: 27
|
15 |
+
Case #15: 19
|
16 |
+
Case #16: 27
|
17 |
+
Case #17: 24
|
18 |
+
Case #18: 20
|
19 |
+
Case #19: impossible
|
20 |
+
Case #20: 62
|
21 |
+
Case #21: 38
|
22 |
+
Case #22: 48
|
23 |
+
Case #23: 43
|
24 |
+
Case #24: 3
|
25 |
+
Case #25: 27
|
26 |
+
Case #26: impossible
|
27 |
+
Case #27: 35
|
28 |
+
Case #28: 65
|
29 |
+
Case #29: 34
|
30 |
+
Case #30: 53
|
31 |
+
Case #31: 14
|
32 |
+
Case #32: 17
|
33 |
+
Case #33: 53
|
34 |
+
Case #34: impossible
|
35 |
+
Case #35: 38
|
36 |
+
Case #36: 1
|
37 |
+
Case #37: 44
|
38 |
+
Case #38: 63
|
39 |
+
Case #39: impossible
|
40 |
+
Case #40: 30
|
41 |
+
Case #41: 46
|
42 |
+
Case #42: 12
|
43 |
+
Case #43: 56
|
44 |
+
Case #44: 30
|
45 |
+
Case #45: 39
|
46 |
+
Case #46: 14
|
47 |
+
Case #47: 110
|
48 |
+
Case #48: impossible
|
49 |
+
Case #49: 87
|
50 |
+
Case #50: 31
|
51 |
+
Case #51: 17
|
52 |
+
Case #52: 6
|
53 |
+
Case #53: impossible
|
54 |
+
Case #54: 9
|
55 |
+
Case #55: impossible
|
56 |
+
Case #56: 4
|
57 |
+
Case #57: impossible
|
58 |
+
Case #58: 65
|
59 |
+
Case #59: 18
|
60 |
+
Case #60: 58
|
61 |
+
Case #61: 105
|
62 |
+
Case #62: 12
|
63 |
+
Case #63: 22
|
64 |
+
Case #64: 53
|
65 |
+
Case #65: impossible
|
66 |
+
Case #66: 125
|
67 |
+
Case #67: impossible
|
68 |
+
Case #68: 53
|
69 |
+
Case #69: 54
|
70 |
+
Case #70: impossible
|
71 |
+
Case #71: impossible
|
72 |
+
Case #72: 41
|
73 |
+
Case #73: 68
|
74 |
+
Case #74: 71
|
75 |
+
Case #75: 76
|
76 |
+
Case #76: 14
|
77 |
+
Case #77: 16
|
78 |
+
Case #78: 78
|
79 |
+
Case #79: impossible
|
80 |
+
Case #80: impossible
|
81 |
+
Case #81: impossible
|
82 |
+
Case #82: impossible
|
83 |
+
Case #83: 99
|
84 |
+
Case #84: 56
|
85 |
+
Case #85: 143
|
86 |
+
Case #86: impossible
|
87 |
+
Case #87: impossible
|
88 |
+
Case #88: 11
|
89 |
+
Case #89: impossible
|
90 |
+
Case #90: 15
|
91 |
+
Case #91: 118
|
92 |
+
Case #92: 36
|
93 |
+
Case #93: 99
|
94 |
+
Case #94: 101
|
95 |
+
Case #95: 141
|
96 |
+
Case #96: impossible
|
97 |
+
Case #97: 24
|
98 |
+
Case #98: 14
|
99 |
+
Case #99: 117
|
100 |
+
Case #100: impossible
|
2015/quals/new_years_resolution.html
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p>
|
2 |
+
Alex's New Year's resolution for 2015 is to eat healthier foods. He's done some
|
3 |
+
research and has found out that calories come from three main sources, called
|
4 |
+
macronutrients: protein, carbohydrates, and fat. Alex wants to get the right
|
5 |
+
balance of protein, carbohydrates, and fat to have a balanced diet.
|
6 |
+
For each available food, Alex can only choose to eat it or not eat it. He
|
7 |
+
can't eat a certain food more than once, and he can't eat a fractional amount
|
8 |
+
of a food.
|
9 |
+
</p>
|
10 |
+
|
11 |
+
<h3>Input</h3>
|
12 |
+
|
13 |
+
<p>
|
14 |
+
Input begins with an integer <strong>T</strong>, the number of test cases.
|
15 |
+
For each test case, the first line consists of three space-separated
|
16 |
+
integers: <strong>G<sub>P</sub></strong>,
|
17 |
+
<strong>G<sub>C</sub></strong>, and <strong>G<sub>F</sub></strong>,
|
18 |
+
which represent the amount of
|
19 |
+
protein, carbohydrates, and fat that Alex wants to eat. The next line has the number of foods for that test case, an integer <strong>N</strong>.
|
20 |
+
The next <strong>N</strong> lines each consist of three space-separated integers:
|
21 |
+
<strong>P</strong>, <strong>C</strong>, and <strong>F</strong>,
|
22 |
+
which represent the amount of protein, carbohydrates, and fat in that food, respectively.
|
23 |
+
</p>
|
24 |
+
|
25 |
+
<h3>Output</h3>
|
26 |
+
|
27 |
+
<p>
|
28 |
+
For each test case <em>i</em>, print a line containing "Case #<em>i</em>: " followed by
|
29 |
+
either "yes" if it is possible for Alex to eat the exact amount of each
|
30 |
+
macronutrient, or "no" if it is not possible.
|
31 |
+
</p>
|
32 |
+
|
33 |
+
<h3>Constraints</h3>
|
34 |
+
|
35 |
+
<p>
|
36 |
+
1 ≤ <strong>T</strong> ≤ 20 <br/>
|
37 |
+
1 ≤ <strong>N</strong> ≤ 20 <br/>
|
38 |
+
10 ≤ <strong>G<sub>P</sub></strong>, <strong>G<sub>C</sub></strong>,
|
39 |
+
<strong>G<sub>F</sub></strong> ≤ 1000 <br/>
|
40 |
+
10 ≤ <strong>P</strong>, <strong>C</strong>, <strong>F</strong> ≤ 1000 <br/>
|
41 |
+
</p>
|
2015/quals/new_years_resolution.in
ADDED
@@ -0,0 +1,1006 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
48
|
2 |
+
100 100 100
|
3 |
+
1
|
4 |
+
100 100 100
|
5 |
+
100 100 100
|
6 |
+
3
|
7 |
+
10 10 40
|
8 |
+
10 30 10
|
9 |
+
10 60 50
|
10 |
+
100 100 100
|
11 |
+
5
|
12 |
+
40 70 30
|
13 |
+
30 10 40
|
14 |
+
20 20 50
|
15 |
+
10 50 90
|
16 |
+
40 10 20
|
17 |
+
292 264 512
|
18 |
+
20
|
19 |
+
909 302 261
|
20 |
+
705 597 823
|
21 |
+
291 51 126
|
22 |
+
28 697 57
|
23 |
+
593 31 826
|
24 |
+
311 256 57
|
25 |
+
292 14 47
|
26 |
+
29 730 716
|
27 |
+
12 529 146
|
28 |
+
768 16 439
|
29 |
+
37 472 15
|
30 |
+
350 192 34
|
31 |
+
163 468 238
|
32 |
+
69 173 10
|
33 |
+
203 72 690
|
34 |
+
424 875 213
|
35 |
+
223 593 292
|
36 |
+
151 46 10
|
37 |
+
88 90 16
|
38 |
+
773 653 711
|
39 |
+
991 827 352
|
40 |
+
20
|
41 |
+
29 560 929
|
42 |
+
139 681 102
|
43 |
+
144 853 10
|
44 |
+
84 729 80
|
45 |
+
218 20 67
|
46 |
+
140 80 901
|
47 |
+
428 20 500
|
48 |
+
520 970 128
|
49 |
+
422 419 30
|
50 |
+
413 101 192
|
51 |
+
467 448 501
|
52 |
+
32 939 684
|
53 |
+
34 20 38
|
54 |
+
251 317 132
|
55 |
+
588 437 10
|
56 |
+
648 21 79
|
57 |
+
391 25 14
|
58 |
+
499 22 24
|
59 |
+
854 77 361
|
60 |
+
405 25 20
|
61 |
+
905 801 686
|
62 |
+
20
|
63 |
+
96 702 733
|
64 |
+
255 767 766
|
65 |
+
813 66 80
|
66 |
+
561 418 216
|
67 |
+
37 778 95
|
68 |
+
765 818 433
|
69 |
+
869 761 45
|
70 |
+
270 635 304
|
71 |
+
623 356 44
|
72 |
+
871 407 13
|
73 |
+
12 303 607
|
74 |
+
972 148 951
|
75 |
+
374 280 16
|
76 |
+
179 191 583
|
77 |
+
38 552 19
|
78 |
+
22 91 66
|
79 |
+
243 981 10
|
80 |
+
13 171 864
|
81 |
+
91 11 129
|
82 |
+
168 728 757
|
83 |
+
686 595 72
|
84 |
+
20
|
85 |
+
484 559 115
|
86 |
+
352 42 892
|
87 |
+
44 674 953
|
88 |
+
686 616 366
|
89 |
+
992 981 409
|
90 |
+
421 30 197
|
91 |
+
744 359 16
|
92 |
+
716 150 327
|
93 |
+
50 518 235
|
94 |
+
207 212 177
|
95 |
+
20 430 588
|
96 |
+
551 690 970
|
97 |
+
25 238 408
|
98 |
+
44 14 140
|
99 |
+
68 708 337
|
100 |
+
235 952 283
|
101 |
+
68 851 120
|
102 |
+
21 790 505
|
103 |
+
275 336 987
|
104 |
+
131 552 16
|
105 |
+
788 804 781
|
106 |
+
20
|
107 |
+
447 71 70
|
108 |
+
274 994 525
|
109 |
+
577 199 427
|
110 |
+
543 963 263
|
111 |
+
438 11 11
|
112 |
+
484 844 38
|
113 |
+
54 125 371
|
114 |
+
123 10 217
|
115 |
+
797 403 18
|
116 |
+
41 527 163
|
117 |
+
487 10 171
|
118 |
+
16 762 912
|
119 |
+
10 932 68
|
120 |
+
694 118 222
|
121 |
+
759 10 22
|
122 |
+
670 917 553
|
123 |
+
107 871 413
|
124 |
+
119 82 410
|
125 |
+
614 472 670
|
126 |
+
230 100 99
|
127 |
+
868 903 789
|
128 |
+
20
|
129 |
+
12 103 782
|
130 |
+
696 535 181
|
131 |
+
632 98 10
|
132 |
+
154 74 998
|
133 |
+
10 240 300
|
134 |
+
95 10 698
|
135 |
+
26 196 686
|
136 |
+
384 930 414
|
137 |
+
12 163 161
|
138 |
+
163 38 440
|
139 |
+
422 15 637
|
140 |
+
355 25 10
|
141 |
+
740 26 930
|
142 |
+
277 740 302
|
143 |
+
328 129 135
|
144 |
+
20 714 250
|
145 |
+
39 730 61
|
146 |
+
822 578 333
|
147 |
+
639 23 10
|
148 |
+
485 16 75
|
149 |
+
588 838 678
|
150 |
+
20
|
151 |
+
314 743 943
|
152 |
+
659 696 10
|
153 |
+
10 10 352
|
154 |
+
223 53 91
|
155 |
+
733 594 19
|
156 |
+
384 64 487
|
157 |
+
15 11 770
|
158 |
+
569 639 471
|
159 |
+
590 613 747
|
160 |
+
777 99 217
|
161 |
+
12 666 132
|
162 |
+
396 456 914
|
163 |
+
186 72 157
|
164 |
+
505 952 153
|
165 |
+
143 56 197
|
166 |
+
380 988 876
|
167 |
+
869 213 672
|
168 |
+
76 388 744
|
169 |
+
68 504 684
|
170 |
+
833 56 709
|
171 |
+
861 761 436
|
172 |
+
20
|
173 |
+
53 70 126
|
174 |
+
176 143 95
|
175 |
+
758 312 907
|
176 |
+
409 183 29
|
177 |
+
887 63 355
|
178 |
+
781 941 21
|
179 |
+
235 192 358
|
180 |
+
43 20 93
|
181 |
+
106 138 551
|
182 |
+
196 10 576
|
183 |
+
195 875 263
|
184 |
+
213 449 401
|
185 |
+
639 73 934
|
186 |
+
655 222 98
|
187 |
+
53 71 141
|
188 |
+
537 976 662
|
189 |
+
669 26 11
|
190 |
+
294 729 93
|
191 |
+
436 17 15
|
192 |
+
246 341 467
|
193 |
+
401 536 646
|
194 |
+
20
|
195 |
+
706 58 262
|
196 |
+
48 13 296
|
197 |
+
716 181 182
|
198 |
+
73 362 146
|
199 |
+
42 629 451
|
200 |
+
74 37 13
|
201 |
+
61 486 435
|
202 |
+
742 480 405
|
203 |
+
353 14 54
|
204 |
+
166 119 607
|
205 |
+
14 408 181
|
206 |
+
12 425 17
|
207 |
+
121 661 194
|
208 |
+
327 499 633
|
209 |
+
11 234 103
|
210 |
+
14 624 86
|
211 |
+
114 491 84
|
212 |
+
482 610 88
|
213 |
+
15 19 722
|
214 |
+
11 293 688
|
215 |
+
734 644 887
|
216 |
+
20
|
217 |
+
676 968 23
|
218 |
+
946 215 329
|
219 |
+
122 851 31
|
220 |
+
219 99 845
|
221 |
+
311 57 422
|
222 |
+
229 117 452
|
223 |
+
114 78 48
|
224 |
+
329 388 63
|
225 |
+
855 924 12
|
226 |
+
335 774 659
|
227 |
+
463 361 424
|
228 |
+
308 947 550
|
229 |
+
191 252 239
|
230 |
+
10 245 760
|
231 |
+
133 369 824
|
232 |
+
860 193 530
|
233 |
+
10 485 782
|
234 |
+
487 197 15
|
235 |
+
852 61 373
|
236 |
+
118 426 365
|
237 |
+
827 994 940
|
238 |
+
20
|
239 |
+
262 846 390
|
240 |
+
19 543 52
|
241 |
+
839 400 405
|
242 |
+
23 859 592
|
243 |
+
420 513 357
|
244 |
+
562 331 218
|
245 |
+
497 141 492
|
246 |
+
748 632 524
|
247 |
+
15 722 48
|
248 |
+
80 521 176
|
249 |
+
815 533 62
|
250 |
+
508 51 171
|
251 |
+
19 291 136
|
252 |
+
674 895 157
|
253 |
+
325 10 62
|
254 |
+
209 362 439
|
255 |
+
12 50 10
|
256 |
+
88 373 711
|
257 |
+
13 58 274
|
258 |
+
287 342 443
|
259 |
+
201 548 847
|
260 |
+
20
|
261 |
+
216 624 923
|
262 |
+
662 104 10
|
263 |
+
910 123 865
|
264 |
+
577 48 802
|
265 |
+
109 200 929
|
266 |
+
411 12 198
|
267 |
+
162 13 43
|
268 |
+
544 150 494
|
269 |
+
156 746 353
|
270 |
+
146 25 126
|
271 |
+
50 42 16
|
272 |
+
747 210 189
|
273 |
+
244 40 83
|
274 |
+
368 16 942
|
275 |
+
606 203 442
|
276 |
+
13 908 775
|
277 |
+
276 35 401
|
278 |
+
384 559 659
|
279 |
+
657 43 216
|
280 |
+
29 210 622
|
281 |
+
812 491 534
|
282 |
+
20
|
283 |
+
663 690 103
|
284 |
+
165 644 334
|
285 |
+
49 26 10
|
286 |
+
267 184 231
|
287 |
+
242 323 171
|
288 |
+
31 273 777
|
289 |
+
549 35 588
|
290 |
+
824 28 53
|
291 |
+
553 68 206
|
292 |
+
772 97 64
|
293 |
+
21 698 558
|
294 |
+
31 10 849
|
295 |
+
10 261 792
|
296 |
+
836 756 11
|
297 |
+
403 860 794
|
298 |
+
670 234 13
|
299 |
+
196 646 532
|
300 |
+
841 396 370
|
301 |
+
994 67 441
|
302 |
+
108 84 243
|
303 |
+
601 522 597
|
304 |
+
20
|
305 |
+
107 130 377
|
306 |
+
48 878 702
|
307 |
+
250 217 15
|
308 |
+
102 122 80
|
309 |
+
271 229 510
|
310 |
+
72 30 15
|
311 |
+
422 124 414
|
312 |
+
784 295 10
|
313 |
+
550 564 649
|
314 |
+
359 792 57
|
315 |
+
95 12 248
|
316 |
+
112 270 247
|
317 |
+
446 281 64
|
318 |
+
11 379 328
|
319 |
+
918 147 824
|
320 |
+
187 156 112
|
321 |
+
114 28 482
|
322 |
+
16 809 83
|
323 |
+
19 64 123
|
324 |
+
701 48 25
|
325 |
+
985 848 926
|
326 |
+
20
|
327 |
+
179 356 12
|
328 |
+
44 490 297
|
329 |
+
126 181 58
|
330 |
+
55 225 110
|
331 |
+
321 99 486
|
332 |
+
115 70 171
|
333 |
+
602 187 844
|
334 |
+
391 11 188
|
335 |
+
53 76 203
|
336 |
+
29 374 307
|
337 |
+
78 959 34
|
338 |
+
182 24 828
|
339 |
+
318 296 43
|
340 |
+
244 72 530
|
341 |
+
161 730 76
|
342 |
+
751 808 296
|
343 |
+
487 54 106
|
344 |
+
857 36 588
|
345 |
+
231 12 118
|
346 |
+
291 62 35
|
347 |
+
415 542 410
|
348 |
+
20
|
349 |
+
22 585 19
|
350 |
+
99 661 543
|
351 |
+
173 46 12
|
352 |
+
10 38 73
|
353 |
+
74 598 77
|
354 |
+
46 730 935
|
355 |
+
49 950 123
|
356 |
+
523 11 17
|
357 |
+
747 751 281
|
358 |
+
691 301 34
|
359 |
+
374 48 608
|
360 |
+
968 10 924
|
361 |
+
400 484 906
|
362 |
+
11 738 36
|
363 |
+
298 270 12
|
364 |
+
238 20 136
|
365 |
+
314 818 666
|
366 |
+
345 374 77
|
367 |
+
472 301 517
|
368 |
+
101 10 129
|
369 |
+
181 750 819
|
370 |
+
20
|
371 |
+
60 10 576
|
372 |
+
303 39 917
|
373 |
+
158 159 42
|
374 |
+
16 499 333
|
375 |
+
115 959 782
|
376 |
+
841 229 358
|
377 |
+
142 10 742
|
378 |
+
181 750 819
|
379 |
+
53 588 951
|
380 |
+
668 160 18
|
381 |
+
10 66 238
|
382 |
+
865 416 10
|
383 |
+
374 107 988
|
384 |
+
149 926 470
|
385 |
+
59 223 914
|
386 |
+
11 564 201
|
387 |
+
23 24 28
|
388 |
+
10 359 455
|
389 |
+
818 159 841
|
390 |
+
132 963 10
|
391 |
+
552 962 915
|
392 |
+
20
|
393 |
+
213 199 214
|
394 |
+
461 68 134
|
395 |
+
63 907 730
|
396 |
+
65 595 102
|
397 |
+
24 466 531
|
398 |
+
526 10 610
|
399 |
+
57 10 181
|
400 |
+
678 30 12
|
401 |
+
511 536 368
|
402 |
+
296 18 772
|
403 |
+
254 10 495
|
404 |
+
784 40 65
|
405 |
+
12 63 668
|
406 |
+
723 11 306
|
407 |
+
255 706 292
|
408 |
+
202 104 51
|
409 |
+
141 46 500
|
410 |
+
478 159 683
|
411 |
+
44 319 28
|
412 |
+
271 192 163
|
413 |
+
524 829 430
|
414 |
+
20
|
415 |
+
45 392 93
|
416 |
+
140 56 30
|
417 |
+
29 42 621
|
418 |
+
249 829 584
|
419 |
+
886 53 26
|
420 |
+
691 215 765
|
421 |
+
174 160 477
|
422 |
+
65 481 367
|
423 |
+
62 239 741
|
424 |
+
48 361 10
|
425 |
+
950 657 395
|
426 |
+
82 712 883
|
427 |
+
202 21 249
|
428 |
+
973 273 110
|
429 |
+
123 277 871
|
430 |
+
11 15 67
|
431 |
+
65 192 182
|
432 |
+
730 28 717
|
433 |
+
168 952 720
|
434 |
+
55 829 760
|
435 |
+
390 818 745
|
436 |
+
20
|
437 |
+
208 14 139
|
438 |
+
694 107 395
|
439 |
+
23 987 19
|
440 |
+
25 786 329
|
441 |
+
493 104 401
|
442 |
+
200 122 23
|
443 |
+
50 386 241
|
444 |
+
827 128 73
|
445 |
+
45 961 682
|
446 |
+
206 366 86
|
447 |
+
15 71 282
|
448 |
+
12 293 553
|
449 |
+
650 454 495
|
450 |
+
148 385 497
|
451 |
+
392 968 334
|
452 |
+
199 387 39
|
453 |
+
973 51 280
|
454 |
+
354 11 672
|
455 |
+
493 127 17
|
456 |
+
540 308 143
|
457 |
+
425 837 606
|
458 |
+
20
|
459 |
+
36 382 976
|
460 |
+
898 10 596
|
461 |
+
773 773 287
|
462 |
+
160 170 135
|
463 |
+
166 13 340
|
464 |
+
412 94 139
|
465 |
+
441 348 778
|
466 |
+
676 103 850
|
467 |
+
134 37 244
|
468 |
+
12 146 165
|
469 |
+
542 14 623
|
470 |
+
264 248 10
|
471 |
+
89 71 18
|
472 |
+
173 27 452
|
473 |
+
340 222 227
|
474 |
+
62 560 446
|
475 |
+
139 245 48
|
476 |
+
15 830 769
|
477 |
+
774 655 30
|
478 |
+
429 216 92
|
479 |
+
459 394 656
|
480 |
+
20
|
481 |
+
42 63 382
|
482 |
+
96 248 26
|
483 |
+
81 18 126
|
484 |
+
17 232 81
|
485 |
+
683 539 847
|
486 |
+
642 336 827
|
487 |
+
449 20 400
|
488 |
+
50 57 835
|
489 |
+
23 301 69
|
490 |
+
564 917 28
|
491 |
+
647 366 151
|
492 |
+
532 768 739
|
493 |
+
812 402 741
|
494 |
+
139 237 804
|
495 |
+
55 148 357
|
496 |
+
173 84 184
|
497 |
+
284 92 851
|
498 |
+
646 18 568
|
499 |
+
318 656 760
|
500 |
+
313 12 79
|
501 |
+
740 805 935
|
502 |
+
20
|
503 |
+
671 884 37
|
504 |
+
365 527 774
|
505 |
+
619 185 48
|
506 |
+
333 125 542
|
507 |
+
355 739 513
|
508 |
+
299 249 12
|
509 |
+
238 247 668
|
510 |
+
10 365 122
|
511 |
+
15 744 212
|
512 |
+
992 709 806
|
513 |
+
20 368 520
|
514 |
+
889 217 399
|
515 |
+
528 547 355
|
516 |
+
314 24 215
|
517 |
+
130 363 807
|
518 |
+
441 556 923
|
519 |
+
477 124 172
|
520 |
+
528 95 447
|
521 |
+
389 129 289
|
522 |
+
36 12 620
|
523 |
+
393 821 883
|
524 |
+
20
|
525 |
+
389 586 269
|
526 |
+
363 927 476
|
527 |
+
156 65 852
|
528 |
+
92 924 146
|
529 |
+
40 332 572
|
530 |
+
205 135 101
|
531 |
+
69 62 351
|
532 |
+
156 849 10
|
533 |
+
35 18 438
|
534 |
+
355 39 774
|
535 |
+
478 477 442
|
536 |
+
59 744 795
|
537 |
+
188 213 136
|
538 |
+
11 712 410
|
539 |
+
703 728 365
|
540 |
+
91 960 333
|
541 |
+
36 157 517
|
542 |
+
880 71 23
|
543 |
+
253 46 520
|
544 |
+
924 39 79
|
545 |
+
292 381 558
|
546 |
+
20
|
547 |
+
10 38 218
|
548 |
+
12 148 673
|
549 |
+
10 471 330
|
550 |
+
844 732 240
|
551 |
+
406 298 322
|
552 |
+
691 617 121
|
553 |
+
752 545 241
|
554 |
+
410 301 823
|
555 |
+
155 641 273
|
556 |
+
955 165 121
|
557 |
+
84 320 64
|
558 |
+
56 60 93
|
559 |
+
18 48 239
|
560 |
+
928 925 34
|
561 |
+
308 625 182
|
562 |
+
13 13 701
|
563 |
+
630 13 212
|
564 |
+
124 304 913
|
565 |
+
289 242 458
|
566 |
+
696 822 421
|
567 |
+
708 39 464
|
568 |
+
20
|
569 |
+
691 490 32
|
570 |
+
10 10 785
|
571 |
+
130 230 92
|
572 |
+
83 66 217
|
573 |
+
30 106 576
|
574 |
+
10 734 108
|
575 |
+
70 193 173
|
576 |
+
501 467 154
|
577 |
+
873 696 10
|
578 |
+
259 285 183
|
579 |
+
205 26 423
|
580 |
+
10 100 10
|
581 |
+
544 920 63
|
582 |
+
357 856 93
|
583 |
+
503 13 41
|
584 |
+
372 62 393
|
585 |
+
438 181 35
|
586 |
+
877 369 662
|
587 |
+
636 897 273
|
588 |
+
23 987 807
|
589 |
+
669 872 698
|
590 |
+
20
|
591 |
+
31 186 451
|
592 |
+
121 759 10
|
593 |
+
517 497 500
|
594 |
+
222 271 26
|
595 |
+
570 347 53
|
596 |
+
81 160 859
|
597 |
+
349 182 365
|
598 |
+
270 845 83
|
599 |
+
949 430 369
|
600 |
+
58 658 421
|
601 |
+
672 117 151
|
602 |
+
102 968 223
|
603 |
+
245 365 122
|
604 |
+
10 25 193
|
605 |
+
672 34 260
|
606 |
+
34 39 65
|
607 |
+
990 163 36
|
608 |
+
13 394 10
|
609 |
+
10 166 55
|
610 |
+
10 504 114
|
611 |
+
291 999 572
|
612 |
+
20
|
613 |
+
514 631 123
|
614 |
+
688 547 135
|
615 |
+
822 542 52
|
616 |
+
95 22 100
|
617 |
+
25 100 384
|
618 |
+
28 174 413
|
619 |
+
37 474 15
|
620 |
+
702 511 465
|
621 |
+
10 26 742
|
622 |
+
616 863 74
|
623 |
+
815 850 707
|
624 |
+
364 10 563
|
625 |
+
48 43 225
|
626 |
+
725 75 62
|
627 |
+
991 270 100
|
628 |
+
26 131 867
|
629 |
+
168 803 59
|
630 |
+
289 408 23
|
631 |
+
70 54 234
|
632 |
+
459 876 640
|
633 |
+
713 395 742
|
634 |
+
20
|
635 |
+
23 71 10
|
636 |
+
354 698 38
|
637 |
+
138 691 869
|
638 |
+
44 11 726
|
639 |
+
166 974 477
|
640 |
+
375 331 445
|
641 |
+
426 182 17
|
642 |
+
938 288 685
|
643 |
+
10 371 432
|
644 |
+
30 808 202
|
645 |
+
955 279 805
|
646 |
+
678 408 752
|
647 |
+
430 62 748
|
648 |
+
269 19 174
|
649 |
+
636 317 203
|
650 |
+
266 296 676
|
651 |
+
13 582 811
|
652 |
+
260 812 11
|
653 |
+
43 805 113
|
654 |
+
813 492 552
|
655 |
+
536 749 776
|
656 |
+
20
|
657 |
+
55 10 724
|
658 |
+
122 264 654
|
659 |
+
10 980 98
|
660 |
+
494 242 170
|
661 |
+
159 814 813
|
662 |
+
615 278 95
|
663 |
+
251 298 381
|
664 |
+
310 43 52
|
665 |
+
735 913 69
|
666 |
+
195 29 266
|
667 |
+
15 324 268
|
668 |
+
12 831 11
|
669 |
+
19 148 12
|
670 |
+
30 323 24
|
671 |
+
417 186 702
|
672 |
+
799 890 338
|
673 |
+
79 615 470
|
674 |
+
540 62 142
|
675 |
+
206 132 220
|
676 |
+
347 15 916
|
677 |
+
397 405 835
|
678 |
+
20
|
679 |
+
335 775 229
|
680 |
+
103 640 993
|
681 |
+
166 43 570
|
682 |
+
560 10 113
|
683 |
+
59 73 39
|
684 |
+
358 11 741
|
685 |
+
63 342 886
|
686 |
+
116 284 622
|
687 |
+
415 788 10
|
688 |
+
126 100 45
|
689 |
+
23 606 19
|
690 |
+
719 107 160
|
691 |
+
13 328 856
|
692 |
+
111 51 451
|
693 |
+
12 32 22
|
694 |
+
755 620 357
|
695 |
+
10 685 618
|
696 |
+
434 49 261
|
697 |
+
615 10 943
|
698 |
+
66 535 921
|
699 |
+
382 993 459
|
700 |
+
20
|
701 |
+
917 103 568
|
702 |
+
776 500 372
|
703 |
+
18 900 13
|
704 |
+
92 367 16
|
705 |
+
803 755 414
|
706 |
+
94 321 521
|
707 |
+
746 421 216
|
708 |
+
313 321 18
|
709 |
+
628 147 561
|
710 |
+
451 65 898
|
711 |
+
747 179 336
|
712 |
+
249 37 590
|
713 |
+
397 166 431
|
714 |
+
248 550 433
|
715 |
+
42 76 10
|
716 |
+
94 56 10
|
717 |
+
353 963 11
|
718 |
+
307 821 100
|
719 |
+
29 994 478
|
720 |
+
588 35 454
|
721 |
+
197 605 392
|
722 |
+
20
|
723 |
+
291 432 777
|
724 |
+
994 340 355
|
725 |
+
166 146 272
|
726 |
+
831 109 693
|
727 |
+
226 501 21
|
728 |
+
884 12 632
|
729 |
+
90 181 105
|
730 |
+
18 977 431
|
731 |
+
46 558 526
|
732 |
+
142 272 660
|
733 |
+
439 315 284
|
734 |
+
13 269 254
|
735 |
+
92 164 320
|
736 |
+
207 902 232
|
737 |
+
137 529 535
|
738 |
+
126 815 388
|
739 |
+
74 450 917
|
740 |
+
584 405 150
|
741 |
+
10 224 589
|
742 |
+
530 282 795
|
743 |
+
771 534 961
|
744 |
+
20
|
745 |
+
291 72 444
|
746 |
+
15 249 256
|
747 |
+
192 25 311
|
748 |
+
325 131 10
|
749 |
+
66 10 67
|
750 |
+
969 135 19
|
751 |
+
360 43 129
|
752 |
+
187 104 756
|
753 |
+
105 226 694
|
754 |
+
179 41 837
|
755 |
+
359 762 422
|
756 |
+
278 241 278
|
757 |
+
534 53 29
|
758 |
+
314 123 740
|
759 |
+
820 299 60
|
760 |
+
562 920 100
|
761 |
+
17 16 211
|
762 |
+
11 64 16
|
763 |
+
125 562 929
|
764 |
+
661 269 546
|
765 |
+
330 906 847
|
766 |
+
20
|
767 |
+
39 716 70
|
768 |
+
142 19 752
|
769 |
+
683 311 640
|
770 |
+
846 374 773
|
771 |
+
14 818 12
|
772 |
+
586 30 36
|
773 |
+
188 887 95
|
774 |
+
242 951 355
|
775 |
+
255 112 650
|
776 |
+
286 978 64
|
777 |
+
15 73 45
|
778 |
+
32 688 37
|
779 |
+
690 481 831
|
780 |
+
187 29 61
|
781 |
+
236 860 147
|
782 |
+
393 897 150
|
783 |
+
558 717 77
|
784 |
+
471 483 682
|
785 |
+
582 108 65
|
786 |
+
102 251 953
|
787 |
+
658 874 116
|
788 |
+
20
|
789 |
+
201 149 224
|
790 |
+
18 834 789
|
791 |
+
41 90 23
|
792 |
+
28 615 25
|
793 |
+
435 144 568
|
794 |
+
777 41 921
|
795 |
+
129 375 447
|
796 |
+
256 804 531
|
797 |
+
439 63 10
|
798 |
+
223 324 105
|
799 |
+
54 204 977
|
800 |
+
669 10 66
|
801 |
+
23 99 12
|
802 |
+
132 600 90
|
803 |
+
302 77 38
|
804 |
+
354 406 307
|
805 |
+
328 182 53
|
806 |
+
14 203 633
|
807 |
+
914 978 14
|
808 |
+
300 15 542
|
809 |
+
410 787 593
|
810 |
+
20
|
811 |
+
157 816 309
|
812 |
+
51 78 20
|
813 |
+
281 125 720
|
814 |
+
29 881 205
|
815 |
+
91 476 664
|
816 |
+
552 985 252
|
817 |
+
414 753 58
|
818 |
+
98 261 469
|
819 |
+
684 57 494
|
820 |
+
206 276 570
|
821 |
+
233 731 655
|
822 |
+
16 226 814
|
823 |
+
28 617 242
|
824 |
+
756 600 176
|
825 |
+
292 259 708
|
826 |
+
949 52 312
|
827 |
+
11 452 87
|
828 |
+
448 919 291
|
829 |
+
20 20 20
|
830 |
+
281 54 17
|
831 |
+
212 742 882
|
832 |
+
20
|
833 |
+
60 808 88
|
834 |
+
705 10 132
|
835 |
+
473 456 113
|
836 |
+
599 186 220
|
837 |
+
182 932 34
|
838 |
+
31 10 719
|
839 |
+
132 843 813
|
840 |
+
383 223 950
|
841 |
+
326 68 61
|
842 |
+
909 564 74
|
843 |
+
32 175 784
|
844 |
+
305 20 62
|
845 |
+
280 193 919
|
846 |
+
746 96 441
|
847 |
+
97 209 10
|
848 |
+
315 989 764
|
849 |
+
320 37 281
|
850 |
+
773 852 44
|
851 |
+
11 920 679
|
852 |
+
371 540 596
|
853 |
+
978 383 580
|
854 |
+
20
|
855 |
+
58 445 25
|
856 |
+
462 16 364
|
857 |
+
44 639 37
|
858 |
+
22 876 239
|
859 |
+
437 128 293
|
860 |
+
540 588 21
|
861 |
+
304 22 249
|
862 |
+
310 957 587
|
863 |
+
29 589 10
|
864 |
+
99 983 763
|
865 |
+
96 49 987
|
866 |
+
119 10 62
|
867 |
+
654 53 10
|
868 |
+
151 435 15
|
869 |
+
13 300 449
|
870 |
+
399 656 102
|
871 |
+
10 158 322
|
872 |
+
215 688 112
|
873 |
+
10 116 576
|
874 |
+
207 283 517
|
875 |
+
826 133 225
|
876 |
+
20
|
877 |
+
109 598 886
|
878 |
+
630 811 280
|
879 |
+
463 241 444
|
880 |
+
101 746 10
|
881 |
+
14 847 927
|
882 |
+
45 742 961
|
883 |
+
10 720 111
|
884 |
+
800 773 320
|
885 |
+
391 13 234
|
886 |
+
594 21 99
|
887 |
+
232 112 126
|
888 |
+
304 965 351
|
889 |
+
907 46 310
|
890 |
+
189 40 168
|
891 |
+
39 80 443
|
892 |
+
234 29 846
|
893 |
+
647 40 56
|
894 |
+
307 66 548
|
895 |
+
407 93 878
|
896 |
+
848 15 186
|
897 |
+
861 317 892
|
898 |
+
20
|
899 |
+
18 145 886
|
900 |
+
649 860 629
|
901 |
+
155 836 119
|
902 |
+
430 13 420
|
903 |
+
712 461 982
|
904 |
+
92 604 10
|
905 |
+
304 69 68
|
906 |
+
128 30 814
|
907 |
+
138 217 726
|
908 |
+
76 17 255
|
909 |
+
332 399 820
|
910 |
+
256 366 30
|
911 |
+
907 304 186
|
912 |
+
76 49 439
|
913 |
+
796 289 273
|
914 |
+
16 515 355
|
915 |
+
10 10 223
|
916 |
+
596 355 758
|
917 |
+
429 218 10
|
918 |
+
573 213 10
|
919 |
+
855 390 629
|
920 |
+
20
|
921 |
+
387 456 303
|
922 |
+
689 97 355
|
923 |
+
440 293 297
|
924 |
+
33 777 143
|
925 |
+
148 769 21
|
926 |
+
729 811 907
|
927 |
+
17 954 233
|
928 |
+
761 15 172
|
929 |
+
102 38 21
|
930 |
+
22 199 198
|
931 |
+
614 916 620
|
932 |
+
42 56 55
|
933 |
+
603 32 829
|
934 |
+
139 53 968
|
935 |
+
689 168 61
|
936 |
+
14 680 22
|
937 |
+
952 147 134
|
938 |
+
307 632 625
|
939 |
+
290 57 773
|
940 |
+
10 13 152
|
941 |
+
828 683 564
|
942 |
+
20
|
943 |
+
526 612 937
|
944 |
+
85 194 532
|
945 |
+
729 56 190
|
946 |
+
29 46 518
|
947 |
+
363 18 134
|
948 |
+
60 741 529
|
949 |
+
321 353 874
|
950 |
+
90 376 71
|
951 |
+
11 391 83
|
952 |
+
52 179 772
|
953 |
+
832 292 690
|
954 |
+
524 434 459
|
955 |
+
571 38 10
|
956 |
+
32 415 58
|
957 |
+
96 352 802
|
958 |
+
47 848 436
|
959 |
+
980 73 621
|
960 |
+
174 60 10
|
961 |
+
60 339 250
|
962 |
+
64 39 423
|
963 |
+
737 308 815
|
964 |
+
20
|
965 |
+
11 117 72
|
966 |
+
13 23 13
|
967 |
+
220 939 229
|
968 |
+
215 852 88
|
969 |
+
20 563 36
|
970 |
+
544 713 524
|
971 |
+
98 626 333
|
972 |
+
15 401 270
|
973 |
+
35 232 110
|
974 |
+
546 458 955
|
975 |
+
25 351 194
|
976 |
+
27 239 494
|
977 |
+
675 206 38
|
978 |
+
40 107 844
|
979 |
+
16 69 753
|
980 |
+
431 504 123
|
981 |
+
33 10 11
|
982 |
+
938 82 14
|
983 |
+
151 186 974
|
984 |
+
230 174 22
|
985 |
+
861 695 625
|
986 |
+
20
|
987 |
+
10 77 445
|
988 |
+
958 23 124
|
989 |
+
398 967 12
|
990 |
+
23 379 811
|
991 |
+
714 78 384
|
992 |
+
59 37 16
|
993 |
+
13 569 71
|
994 |
+
113 129 32
|
995 |
+
688 20 215
|
996 |
+
158 267 96
|
997 |
+
823 123 170
|
998 |
+
353 483 10
|
999 |
+
964 560 17
|
1000 |
+
75 11 154
|
1001 |
+
21 356 125
|
1002 |
+
10 281 16
|
1003 |
+
760 157 656
|
1004 |
+
13 651 599
|
1005 |
+
888 314 10
|
1006 |
+
474 876 659
|
2015/quals/new_years_resolution.md
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Alex's New Year's resolution for 2015 is to eat healthier foods. He's done
|
2 |
+
some research and has found out that calories come from three main sources,
|
3 |
+
called macronutrients: protein, carbohydrates, and fat. Alex wants to get the
|
4 |
+
right balance of protein, carbohydrates, and fat to have a balanced diet. For
|
5 |
+
each available food, Alex can only choose to eat it or not eat it. He can't
|
6 |
+
eat a certain food more than once, and he can't eat a fractional amount of a
|
7 |
+
food.
|
8 |
+
|
9 |
+
### Input
|
10 |
+
|
11 |
+
Input begins with an integer **T**, the number of test cases. For each test
|
12 |
+
case, the first line consists of three space-separated integers: **GP**,
|
13 |
+
**GC**, and **GF**, which represent the amount of protein, carbohydrates, and
|
14 |
+
fat that Alex wants to eat. The next line has the number of foods for that
|
15 |
+
test case, an integer **N**. The next **N** lines each consist of three space-
|
16 |
+
separated integers: **P**, **C**, and **F**, which represent the amount of
|
17 |
+
protein, carbohydrates, and fat in that food, respectively.
|
18 |
+
|
19 |
+
### Output
|
20 |
+
|
21 |
+
For each test case _i_, print a line containing "Case #_i_: " followed by
|
22 |
+
either "yes" if it is possible for Alex to eat the exact amount of each
|
23 |
+
macronutrient, or "no" if it is not possible.
|
24 |
+
|
25 |
+
### Constraints
|
26 |
+
|
27 |
+
1 ≤ **T** ≤ 20
|
28 |
+
1 ≤ **N** ≤ 20
|
29 |
+
10 ≤ **GP**, **GC**, **GF** ≤ 1000
|
30 |
+
10 ≤ **P**, **C**, **F** ≤ 1000
|
31 |
+
|
2015/quals/new_years_resolution.out
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Case #1: yes
|
2 |
+
Case #2: no
|
3 |
+
Case #3: yes
|
4 |
+
Case #4: no
|
5 |
+
Case #5: yes
|
6 |
+
Case #6: yes
|
7 |
+
Case #7: no
|
8 |
+
Case #8: no
|
9 |
+
Case #9: no
|
10 |
+
Case #10: no
|
11 |
+
Case #11: no
|
12 |
+
Case #12: yes
|
13 |
+
Case #13: yes
|
14 |
+
Case #14: yes
|
15 |
+
Case #15: no
|
16 |
+
Case #16: no
|
17 |
+
Case #17: no
|
18 |
+
Case #18: no
|
19 |
+
Case #19: no
|
20 |
+
Case #20: yes
|
21 |
+
Case #21: no
|
22 |
+
Case #22: no
|
23 |
+
Case #23: no
|
24 |
+
Case #24: no
|
25 |
+
Case #25: yes
|
26 |
+
Case #26: yes
|
27 |
+
Case #27: no
|
28 |
+
Case #28: no
|
29 |
+
Case #29: yes
|
30 |
+
Case #30: no
|
31 |
+
Case #31: yes
|
32 |
+
Case #32: no
|
33 |
+
Case #33: no
|
34 |
+
Case #34: no
|
35 |
+
Case #35: yes
|
36 |
+
Case #36: no
|
37 |
+
Case #37: no
|
38 |
+
Case #38: yes
|
39 |
+
Case #39: yes
|
40 |
+
Case #40: yes
|
41 |
+
Case #41: no
|
42 |
+
Case #42: no
|
43 |
+
Case #43: yes
|
44 |
+
Case #44: yes
|
45 |
+
Case #45: yes
|
46 |
+
Case #46: no
|
47 |
+
Case #47: yes
|
48 |
+
Case #48: yes
|
2015/round1/autocomplete.html
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p>
|
2 |
+
Since you crave state-of-the-art technology, you've just purchased a phone with a great new feature: autocomplete!
|
3 |
+
Your phone's version of autocomplete has some pros and cons. On the one hand, it's very cautious. It only autocompletes a word when it knows exactly what you're trying to write. On the other hand, you have to teach it every word you want to use.
|
4 |
+
</p>
|
5 |
+
|
6 |
+
<p>
|
7 |
+
You have <strong>N</strong> distinct words that you'd like to send in a text message in order.
|
8 |
+
Before sending each word, you add it to your phone's dictionary.
|
9 |
+
Then, you write the smallest non-empty prefix of the word necessary for your phone to autocomplete the word.
|
10 |
+
This prefix must either be the whole word, or a prefix which is not a prefix of any other word yet in the dictionary.
|
11 |
+
</p>
|
12 |
+
|
13 |
+
<p>
|
14 |
+
What's the minimum number of letters you must type to send all <strong>N</strong> words?
|
15 |
+
</p>
|
16 |
+
|
17 |
+
<h3>Input</h3>
|
18 |
+
|
19 |
+
<p>
|
20 |
+
Input begins with an integer <strong>T</strong>, the number of test cases.
|
21 |
+
For each test case, there is first a line containing the integer <strong>N</strong>.
|
22 |
+
Then, <strong>N</strong> lines follow, each containing a word to send in the order you wish to send them.
|
23 |
+
</p>
|
24 |
+
|
25 |
+
|
26 |
+
<h3>Output</h3>
|
27 |
+
|
28 |
+
<p>
|
29 |
+
For the <strong>i</strong>th test case, print a line containing "Case #<strong>i</strong>: " followed by
|
30 |
+
the minimum number of characters you need to type in your text message.
|
31 |
+
</p>
|
32 |
+
|
33 |
+
|
34 |
+
<h3>Constraints</h3>
|
35 |
+
<p>
|
36 |
+
1 ≤ <strong>T</strong> ≤ 100 <br />
|
37 |
+
1 ≤ <strong>N</strong> ≤ 100,000 <br />
|
38 |
+
</p>
|
39 |
+
|
40 |
+
<p>
|
41 |
+
The <strong>N</strong> words will have a total length of no more than 1,000,000 characters. <br />
|
42 |
+
The words are made up of only lower-case alphabetic characters. <br />
|
43 |
+
The words are pairwise distinct. <br />
|
44 |
+
</p>
|
45 |
+
|
46 |
+
<p>
|
47 |
+
<strong>NOTE:</strong> The input file is about 10-20MB.
|
48 |
+
</p>
|
49 |
+
|
50 |
+
|
51 |
+
<h3>Explanation of Sample</h3>
|
52 |
+
<p>
|
53 |
+
In the first test case, you will write "h", "he", "l", "hil", "hill", for a total of 1 + 2 + 1 + 3 + 4 = 11 characters.
|
54 |
+
</p>
|
2015/round1/autocomplete.in
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a8269902a9c44cbcddece37288fa31a4a5a6fabe963b509b61abad752a4c24ee
|
3 |
+
size 15800792
|
2015/round1/autocomplete.md
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Since you crave state-of-the-art technology, you've just purchased a phone
|
2 |
+
with a great new feature: autocomplete! Your phone's version of autocomplete
|
3 |
+
has some pros and cons. On the one hand, it's very cautious. It only
|
4 |
+
autocompletes a word when it knows exactly what you're trying to write. On the
|
5 |
+
other hand, you have to teach it every word you want to use.
|
6 |
+
|
7 |
+
You have **N** distinct words that you'd like to send in a text message in
|
8 |
+
order. Before sending each word, you add it to your phone's dictionary. Then,
|
9 |
+
you write the smallest non-empty prefix of the word necessary for your phone
|
10 |
+
to autocomplete the word. This prefix must either be the whole word, or a
|
11 |
+
prefix which is not a prefix of any other word yet in the dictionary.
|
12 |
+
|
13 |
+
What's the minimum number of letters you must type to send all **N** words?
|
14 |
+
|
15 |
+
### Input
|
16 |
+
|
17 |
+
Input begins with an integer **T**, the number of test cases. For each test
|
18 |
+
case, there is first a line containing the integer **N**. Then, **N** lines
|
19 |
+
follow, each containing a word to send in the order you wish to send them.
|
20 |
+
|
21 |
+
### Output
|
22 |
+
|
23 |
+
For the **i**th test case, print a line containing "Case #**i**: " followed by
|
24 |
+
the minimum number of characters you need to type in your text message.
|
25 |
+
|
26 |
+
### Constraints
|
27 |
+
|
28 |
+
1 ≤ **T** ≤ 100
|
29 |
+
1 ≤ **N** ≤ 100,000
|
30 |
+
|
31 |
+
The **N** words will have a total length of no more than 1,000,000 characters.
|
32 |
+
The words are made up of only lower-case alphabetic characters.
|
33 |
+
The words are pairwise distinct.
|
34 |
+
|
35 |
+
**NOTE:** The input file is about 10-20MB.
|
36 |
+
|
37 |
+
### Explanation of Sample
|
38 |
+
|
39 |
+
In the first test case, you will write "h", "he", "l", "hil", "hill", for a
|
40 |
+
total of 1 + 2 + 1 + 3 + 4 = 11 characters.
|
41 |
+
|
2015/round1/autocomplete.out
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Case #1: 11
|
2 |
+
Case #2: 15
|
3 |
+
Case #3: 11
|
4 |
+
Case #4: 9
|
5 |
+
Case #5: 3
|
6 |
+
Case #6: 5
|
7 |
+
Case #7: 7
|
8 |
+
Case #8: 21
|
9 |
+
Case #9: 11
|
10 |
+
Case #10: 8
|
11 |
+
Case #11: 6
|
12 |
+
Case #12: 392349
|
13 |
+
Case #13: 392300
|
14 |
+
Case #14: 392395
|
15 |
+
Case #15: 392443
|
16 |
+
Case #16: 392341
|
17 |
+
Case #17: 392317
|
18 |
+
Case #18: 392436
|
19 |
+
Case #19: 392416
|
20 |
+
Case #20: 1
|
21 |
+
Case #21: 180
|
22 |
+
Case #22: 183
|
23 |
+
Case #23: 182
|
24 |
+
Case #24: 179
|
25 |
+
Case #25: 12
|
26 |
+
Case #26: 11
|
2015/round1/corporate_gifting.html
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p>
|
2 |
+
The fine people of Corpro Corp. are a festive bunch. Every holiday season, everybody buys a gift for their manager. A cynic might say that the employees are just trying to bribe their way to a better performance review, but if you asked them yourself, they'd say they just wanted to spread cheer.
|
3 |
+
</p>
|
4 |
+
|
5 |
+
<p>
|
6 |
+
The fine people of Corpro Corp. are a frugal bunch. When they buy gifts, they cooperate to collectively buy the least expensive gifts that they can. A cynic might say that the employees are cheap, but if you asked them yourself, they'd say it's the thought that counts.
|
7 |
+
</p>
|
8 |
+
|
9 |
+
<p>
|
10 |
+
There are <strong>N</strong> employees working at Corpro Corp., and each of them has a manager, except for the CEO who has no manager (the CEO also buys a gift every year, but she donates it to charity).
|
11 |
+
The employees each have a unique employee ID which is an integer from 1 to <strong>N</strong>. As you might expect, the CEO has the ID 1.
|
12 |
+
</p>
|
13 |
+
|
14 |
+
<p>
|
15 |
+
If there exists a set of two or more employees
|
16 |
+
{<strong>p<sub>1</sub></strong>, ...,
|
17 |
+
<strong>p<sub>k</sub></strong>}
|
18 |
+
such that, for all <strong>i</strong> < <strong>k</strong>,
|
19 |
+
<strong>p<sub>i</sub></strong> is the manager of <strong>p<sub>i+1</sub></strong>,
|
20 |
+
then we say that <strong>p<sub>1</sub></strong> is "responsible for" <strong>p<sub>k</sub></strong>.
|
21 |
+
There are never two employees who are responsible for each other.
|
22 |
+
That would be a silly hierarchy indeed.
|
23 |
+
</p>
|
24 |
+
|
25 |
+
<p>
|
26 |
+
There are <strong>N</strong> kinds of gifts available for purchase, and the <strong>i</strong>th kind of gift costs <strong>i</strong> dollars. That is, the prices of the different kinds of gifts are {$1, $2, $3, ... $<strong>N</strong>}. There are <strong>N</strong> copies of each gift available for purchase.
|
27 |
+
</p>
|
28 |
+
|
29 |
+
<p>
|
30 |
+
The only thing that stops all employees from purchasing gifts that cost $1 is the awkwardness of buying a gift for their manager that's the same as the one their manager is giving away. No employee would ever do such a thing!
|
31 |
+
</p>
|
32 |
+
|
33 |
+
<p>
|
34 |
+
For example, in a company with just 2 employees, at least $3 must be spent in total. If employee #1 (the CEO) buys a $1 gift to donate to charity, then employee #2 cannot buy a $1 gift for employee #1 (their manager), but they can buy a $2 gift instead. Note that it would be equally optimal for the CEO to buy a $2 gift, while receiving a $1 gift from her subordinate.
|
35 |
+
</p>
|
36 |
+
|
37 |
+
<p>
|
38 |
+
What's the minimum possible total expenditure across the whole company during the gift exchange?
|
39 |
+
</p>
|
40 |
+
|
41 |
+
|
42 |
+
<h3>Input</h3>
|
43 |
+
|
44 |
+
<p>
|
45 |
+
Input begins with an integer <strong>T</strong>, the number of corporate hierarchies to consider.
|
46 |
+
Each hierarchy is made up of two lines.
|
47 |
+
The first line contains the integer <strong>N</strong>.
|
48 |
+
The second line contains <strong>N</strong> space-separated integers.
|
49 |
+
The <strong>i</strong>th integer is the employee ID of the manager of employee <strong>i</strong>,
|
50 |
+
with the exception that the first integer is always 0, denoting that the CEO has no manager.
|
51 |
+
</p>
|
52 |
+
|
53 |
+
|
54 |
+
|
55 |
+
<h3>Output</h3>
|
56 |
+
|
57 |
+
<p>
|
58 |
+
For the <strong>i</strong>th hierarchy, print a line containing "Case #<strong>i</strong>: " followed by the smallest amount of money the entire company would need to spend.
|
59 |
+
</p>
|
60 |
+
|
61 |
+
<h3>Constraints</h3>
|
62 |
+
|
63 |
+
<p>
|
64 |
+
1 ≤ <strong>T</strong> ≤ 100 <br />
|
65 |
+
1 ≤ <strong>N</strong> ≤ 200,000 <br />
|
66 |
+
</p>
|
67 |
+
|
68 |
+
<p>
|
69 |
+
<strong>NOTE:</strong> The input file is about 10-20MB.
|
70 |
+
</p>
|
71 |
+
|
72 |
+
<h3>Explanation of Sample</h3>
|
73 |
+
<p>
|
74 |
+
In the first test case, the CEO will spend $2, and the other employees will spend $1.
|
75 |
+
</p>
|
76 |
+
|
77 |
+
<p>
|
78 |
+
In the second test case, employees #2 and #3 will spend $2, and the other employees will spend $1.
|
79 |
+
</p>
|
2015/round1/corporate_gifting.in
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e5d12d3817b9daeef9b5ea9fc8f6eecf5f0aeccbd49632908ca9bb6f10b613b1
|
3 |
+
size 26495892
|
2015/round1/corporate_gifting.md
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
The fine people of Corpro Corp. are a festive bunch. Every holiday season,
|
2 |
+
everybody buys a gift for their manager. A cynic might say that the employees
|
3 |
+
are just trying to bribe their way to a better performance review, but if you
|
4 |
+
asked them yourself, they'd say they just wanted to spread cheer.
|
5 |
+
|
6 |
+
The fine people of Corpro Corp. are a frugal bunch. When they buy gifts, they
|
7 |
+
cooperate to collectively buy the least expensive gifts that they can. A cynic
|
8 |
+
might say that the employees are cheap, but if you asked them yourself, they'd
|
9 |
+
say it's the thought that counts.
|
10 |
+
|
11 |
+
There are **N** employees working at Corpro Corp., and each of them has a
|
12 |
+
manager, except for the CEO who has no manager (the CEO also buys a gift every
|
13 |
+
year, but she donates it to charity). The employees each have a unique
|
14 |
+
employee ID which is an integer from 1 to **N**. As you might expect, the CEO
|
15 |
+
has the ID 1.
|
16 |
+
|
17 |
+
If there exists a set of two or more employees {**p1**, ..., **pk**} such
|
18 |
+
that, for all **i** < **k**, **pi** is the manager of **pi+1**, then we say
|
19 |
+
that **p1** is "responsible for" **pk**. There are never two employees who are
|
20 |
+
responsible for each other. That would be a silly hierarchy indeed.
|
21 |
+
|
22 |
+
There are **N** kinds of gifts available for purchase, and the **i**th kind of
|
23 |
+
gift costs **i** dollars. That is, the prices of the different kinds of gifts
|
24 |
+
are {$1, $2, $3, ... $**N**}. There are **N** copies of each gift available
|
25 |
+
for purchase.
|
26 |
+
|
27 |
+
The only thing that stops all employees from purchasing gifts that cost $1 is
|
28 |
+
the awkwardness of buying a gift for their manager that's the same as the one
|
29 |
+
their manager is giving away. No employee would ever do such a thing!
|
30 |
+
|
31 |
+
For example, in a company with just 2 employees, at least $3 must be spent in
|
32 |
+
total. If employee #1 (the CEO) buys a $1 gift to donate to charity, then
|
33 |
+
employee #2 cannot buy a $1 gift for employee #1 (their manager), but they can
|
34 |
+
buy a $2 gift instead. Note that it would be equally optimal for the CEO to
|
35 |
+
buy a $2 gift, while receiving a $1 gift from her subordinate.
|
36 |
+
|
37 |
+
What's the minimum possible total expenditure across the whole company during
|
38 |
+
the gift exchange?
|
39 |
+
|
40 |
+
### Input
|
41 |
+
|
42 |
+
Input begins with an integer **T**, the number of corporate hierarchies to
|
43 |
+
consider. Each hierarchy is made up of two lines. The first line contains the
|
44 |
+
integer **N**. The second line contains **N** space-separated integers. The
|
45 |
+
**i**th integer is the employee ID of the manager of employee **i**, with the
|
46 |
+
exception that the first integer is always 0, denoting that the CEO has no
|
47 |
+
manager.
|
48 |
+
|
49 |
+
### Output
|
50 |
+
|
51 |
+
For the **i**th hierarchy, print a line containing "Case #**i**: " followed by
|
52 |
+
the smallest amount of money the entire company would need to spend.
|
53 |
+
|
54 |
+
### Constraints
|
55 |
+
|
56 |
+
1 ≤ **T** ≤ 100
|
57 |
+
1 ≤ **N** ≤ 200,000
|
58 |
+
|
59 |
+
**NOTE:** The input file is about 10-20MB.
|
60 |
+
|
61 |
+
### Explanation of Sample
|
62 |
+
|
63 |
+
In the first test case, the CEO will spend $2, and the other employees will
|
64 |
+
spend $1.
|
65 |
+
|
66 |
+
In the second test case, employees #2 and #3 will spend $2, and the other
|
67 |
+
employees will spend $1.
|
68 |
+
|
2015/round1/corporate_gifting.out
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Case #1: 4
|
2 |
+
Case #2: 10
|
3 |
+
Case #3: 7
|
4 |
+
Case #4: 12
|
5 |
+
Case #5: 11
|
6 |
+
Case #6: 19
|
7 |
+
Case #7: 29
|
8 |
+
Case #8: 16
|
9 |
+
Case #9: 15
|
10 |
+
Case #10: 300000
|
11 |
+
Case #11: 266675
|
12 |
+
Case #12: 250006
|
13 |
+
Case #13: 240007
|
14 |
+
Case #14: 233343
|
15 |
+
Case #15: 228579
|
16 |
+
Case #16: 225006
|
17 |
+
Case #17: 222229
|
18 |
+
Case #18: 220009
|
19 |
+
Case #19: 218187
|
20 |
+
Case #20: 200001
|
21 |
+
Case #21: 200201
|
22 |
+
Case #22: 259808
|
23 |
+
Case #23: 156560
|
24 |
+
Case #24: 83876
|
25 |
+
Case #25: 270049
|
26 |
+
Case #26: 280835
|
27 |
+
Case #27: 289329
|
28 |
+
Case #28: 289267
|
29 |
+
Case #29: 289121
|
30 |
+
Case #30: 289201
|
31 |
+
Case #31: 289287
|
32 |
+
Case #32: 289251
|
33 |
+
Case #33: 289164
|
34 |
+
Case #34: 289301
|
2015/round1/homework.html
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p>
|
2 |
+
Your first-grade math teacher, Mr. Book, has just introduced you to an amazing new concept — primes! According to your notes, a prime is a positive integer greater than 1 that is divisible by only 1 and itself.
|
3 |
+
</p>
|
4 |
+
|
5 |
+
<p>
|
6 |
+
Primes seem fun, but without giving you and your 6-year-old colleagues time to consider their implications, he's promptly gone on to define another term: primacity. He explains that the primacity of an integer is the number of distinct primes which divide it. For example, the primacity of 12 is 2 (as it's divisible by primes 2 and 3), the primacity of 550 is 3 (as it's divisible by primes 2, 5, and 11), and the primacity of 7 is 1 (as the only prime it's divisible by is 7).
|
7 |
+
</p>
|
8 |
+
|
9 |
+
<p>
|
10 |
+
Following his lesson, Mr. Book has given you homework with some rather mean questions of the following form: Given 3 integers <strong>A</strong>, <strong>B</strong>, and <strong>K</strong>, how many integers in the inclusive range [<strong>A</strong>, <strong>B</strong>] have a primacity of exactly <strong>K</strong>?
|
11 |
+
</p>
|
12 |
+
|
13 |
+
<p>
|
14 |
+
Mr. Book probably expects his little homework assignment to take you and your classmates the rest of the year to complete, giving him time to slack off and nap during the remaining math classes. However, you want to learn more things from him instead! Can you use the skills you've learned in your first-grade computer science classes to finish Mr. Book's homework before tomorrow's math class?
|
15 |
+
</p>
|
16 |
+
|
17 |
+
<h3>Input</h3>
|
18 |
+
|
19 |
+
<p>
|
20 |
+
Input begins with an integer <strong>T</strong>, the number of homework questions. For each question, there is one line containing 3 space-separated integers: <strong>A</strong>, <strong>B</strong>, and <strong>K</strong>.
|
21 |
+
</p>
|
22 |
+
|
23 |
+
|
24 |
+
<h3>Output</h3>
|
25 |
+
|
26 |
+
<p>
|
27 |
+
For the <strong>i</strong>th question, print a line containing "Case #<strong>i</strong>: " followed by the number of integers in the inclusive range [<strong>A</strong>, <strong>B</strong>] with a primacity of <strong>K</strong>.
|
28 |
+
</p>
|
29 |
+
|
30 |
+
|
31 |
+
<h3>Constraints</h3>
|
32 |
+
<p>
|
33 |
+
1 ≤ <strong>T</strong> ≤ 100 <br />
|
34 |
+
2 ≤ <strong>A</strong> ≤ <strong> B</strong> ≤ 10<sup>7</sup> <br />
|
35 |
+
1 ≤ <strong>K</strong> ≤ 10<sup>9</sup> <br />
|
36 |
+
</p>
|
37 |
+
|
38 |
+
<h3>Explanation of Sample</h3>
|
39 |
+
<p>
|
40 |
+
In the first test case, the numbers in the inclusive range [5, 15] with primacity 2 are 6, 10, 12, 14, and 15. All other numbers in this range have primacity 1.
|
41 |
+
</p>
|
42 |
+
|
2015/round1/homework.in
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
100
|
2 |
+
5 15 2
|
3 |
+
2 10 1
|
4 |
+
24 42 3
|
5 |
+
1000000 1000000 1
|
6 |
+
1000000 1000000 2
|
7 |
+
2 10000000 1
|
8 |
+
2 10000000 2
|
9 |
+
2 10000000 3
|
10 |
+
2 10000000 4
|
11 |
+
2 10000000 5
|
12 |
+
2 10000000 6
|
13 |
+
2 10000000 7
|
14 |
+
2 10000000 8
|
15 |
+
2 10000000 9
|
16 |
+
2 10000000 10
|
17 |
+
8871874 9106921 3
|
18 |
+
331489 365258 3
|
19 |
+
1673990 4964281 4
|
20 |
+
2538323 6179886 2
|
21 |
+
1025453 8126648 3
|
22 |
+
3361449 8066195 5
|
23 |
+
2174560 8350603 5
|
24 |
+
1924670 7300066 4
|
25 |
+
3356201 7892516 1
|
26 |
+
6106950 8813219 2
|
27 |
+
3727417 4063511 4
|
28 |
+
3906481 8482851 1
|
29 |
+
1190025 5884818 4
|
30 |
+
3530768 3862846 2
|
31 |
+
3639960 4537222 2
|
32 |
+
4676591 6532150 3
|
33 |
+
5920093 9632621 2
|
34 |
+
5974475 8755316 5
|
35 |
+
2055959 3285607 1
|
36 |
+
5962779 7546760 4
|
37 |
+
7616599 9656814 3
|
38 |
+
819395 5881718 3
|
39 |
+
4540063 9776151 3
|
40 |
+
3149358 4816092 4
|
41 |
+
859164 9298582 3
|
42 |
+
5182061 8775862 5
|
43 |
+
106155 1892761 1
|
44 |
+
1183683 1981007 2
|
45 |
+
2607093 8066130 2
|
46 |
+
2774448 6482213 2
|
47 |
+
6088359 9056768 4
|
48 |
+
152581 3587075 3
|
49 |
+
6558386 7695670 1
|
50 |
+
3076816 8569562 4
|
51 |
+
4384507 7991697 5
|
52 |
+
1620670 8969214 4
|
53 |
+
2758646 8066510 4
|
54 |
+
1832012 3474647 5
|
55 |
+
4681249 9985120 2
|
56 |
+
1542709 7820522 3
|
57 |
+
6581283 7345664 4
|
58 |
+
5400108 8500614 4
|
59 |
+
71201 3452422 5
|
60 |
+
6236504 6406553 3
|
61 |
+
1212007 8814797 5
|
62 |
+
280161 4022288 4
|
63 |
+
5998828 9313139 3
|
64 |
+
3334556 6692366 2
|
65 |
+
4238738 8482756 2
|
66 |
+
1397629 4490703 1
|
67 |
+
5239504 5466741 1
|
68 |
+
1115185 2191541 5
|
69 |
+
1004498 3467821 3
|
70 |
+
249829 4915791 1
|
71 |
+
1268386 7040359 5
|
72 |
+
3165210 8983866 2
|
73 |
+
313542 9645661 4
|
74 |
+
3316911 8040431 4
|
75 |
+
1294444 1873758 2
|
76 |
+
5151921 6733095 2
|
77 |
+
3466230 7052925 4
|
78 |
+
5217611 9465564 2
|
79 |
+
372758 8901763 1
|
80 |
+
3650751 7274864 3
|
81 |
+
328169 7413213 3
|
82 |
+
1537426 4324540 2
|
83 |
+
3472440 5658810 1
|
84 |
+
732178 3267497 4
|
85 |
+
6742737 8769166 2
|
86 |
+
1645327 6034975 3
|
87 |
+
1119888 3311178 3
|
88 |
+
8087077 9505792 4
|
89 |
+
1515067 4051848 3
|
90 |
+
7034691 7549385 4
|
91 |
+
3254111 9037177 3
|
92 |
+
5931909 6822709 3
|
93 |
+
9044939 9418713 5
|
94 |
+
1074662 6227284 2
|
95 |
+
8201820 9209955 3
|
96 |
+
6245823 9177823 4
|
97 |
+
426284 9502658 4
|
98 |
+
847145 6488989 4
|
99 |
+
115606 3742378 3
|
100 |
+
6055091 6351638 1
|
101 |
+
5154586 9431441 4
|
2015/round1/homework.md
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Your first-grade math teacher, Mr. Book, has just introduced you to an amazing
|
2 |
+
new concept — primes! According to your notes, a prime is a positive integer
|
3 |
+
greater than 1 that is divisible by only 1 and itself.
|
4 |
+
|
5 |
+
Primes seem fun, but without giving you and your 6-year-old colleagues time to
|
6 |
+
consider their implications, he's promptly gone on to define another term:
|
7 |
+
primacity. He explains that the primacity of an integer is the number of
|
8 |
+
distinct primes which divide it. For example, the primacity of 12 is 2 (as
|
9 |
+
it's divisible by primes 2 and 3), the primacity of 550 is 3 (as it's
|
10 |
+
divisible by primes 2, 5, and 11), and the primacity of 7 is 1 (as the only
|
11 |
+
prime it's divisible by is 7).
|
12 |
+
|
13 |
+
Following his lesson, Mr. Book has given you homework with some rather mean
|
14 |
+
questions of the following form: Given 3 integers **A**, **B**, and **K**, how
|
15 |
+
many integers in the inclusive range [**A**, **B**] have a primacity of
|
16 |
+
exactly **K**?
|
17 |
+
|
18 |
+
Mr. Book probably expects his little homework assignment to take you and your
|
19 |
+
classmates the rest of the year to complete, giving him time to slack off and
|
20 |
+
nap during the remaining math classes. However, you want to learn more things
|
21 |
+
from him instead! Can you use the skills you've learned in your first-grade
|
22 |
+
computer science classes to finish Mr. Book's homework before tomorrow's math
|
23 |
+
class?
|
24 |
+
|
25 |
+
### Input
|
26 |
+
|
27 |
+
Input begins with an integer **T**, the number of homework questions. For each
|
28 |
+
question, there is one line containing 3 space-separated integers: **A**,
|
29 |
+
**B**, and **K**.
|
30 |
+
|
31 |
+
### Output
|
32 |
+
|
33 |
+
For the **i**th question, print a line containing "Case #**i**: " followed by
|
34 |
+
the number of integers in the inclusive range [**A**, **B**] with a primacity
|
35 |
+
of **K**.
|
36 |
+
|
37 |
+
### Constraints
|
38 |
+
|
39 |
+
1 ≤ **T** ≤ 100
|
40 |
+
2 ≤ **A** ≤ ** B** ≤ 107
|
41 |
+
1 ≤ **K** ≤ 109
|
42 |
+
|
43 |
+
### Explanation of Sample
|
44 |
+
|
45 |
+
In the first test case, the numbers in the inclusive range [5, 15] with
|
46 |
+
primacity 2 are 6, 10, 12, 14, and 15. All other numbers in this range have
|
47 |
+
primacity 1.
|
48 |
+
|
2015/round1/homework.out
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Case #1: 5
|
2 |
+
Case #2: 7
|
3 |
+
Case #3: 2
|
4 |
+
Case #4: 0
|
5 |
+
Case #5: 1
|
6 |
+
Case #6: 665134
|
7 |
+
Case #7: 2536838
|
8 |
+
Case #8: 3642766
|
9 |
+
Case #9: 2389433
|
10 |
+
Case #10: 691209
|
11 |
+
Case #11: 72902
|
12 |
+
Case #12: 1716
|
13 |
+
Case #13: 1
|
14 |
+
Case #14: 0
|
15 |
+
Case #15: 0
|
16 |
+
Case #16: 84004
|
17 |
+
Case #17: 12862
|
18 |
+
Case #18: 784848
|
19 |
+
Case #19: 914083
|
20 |
+
Case #20: 2583098
|
21 |
+
Case #21: 347576
|
22 |
+
Case #22: 448087
|
23 |
+
Case #23: 1299171
|
24 |
+
Case #24: 292564
|
25 |
+
Case #25: 660355
|
26 |
+
Case #26: 81003
|
27 |
+
Case #27: 293161
|
28 |
+
Case #28: 1120812
|
29 |
+
Case #29: 83853
|
30 |
+
Case #30: 225659
|
31 |
+
Case #31: 670494
|
32 |
+
Case #32: 904582
|
33 |
+
Case #33: 214116
|
34 |
+
Case #34: 83227
|
35 |
+
Case #35: 389544
|
36 |
+
Case #36: 730874
|
37 |
+
Case #37: 1852500
|
38 |
+
Case #38: 1883852
|
39 |
+
Case #39: 401548
|
40 |
+
Case #40: 3065358
|
41 |
+
Case #41: 274279
|
42 |
+
Case #42: 131610
|
43 |
+
Case #43: 210840
|
44 |
+
Case #44: 1357770
|
45 |
+
Case #45: 927957
|
46 |
+
Case #46: 732942
|
47 |
+
Case #47: 1273260
|
48 |
+
Case #48: 72187
|
49 |
+
Case #49: 1341249
|
50 |
+
Case #50: 270356
|
51 |
+
Case #51: 1782942
|
52 |
+
Case #52: 1292370
|
53 |
+
Case #53: 107363
|
54 |
+
Case #54: 1297115
|
55 |
+
Case #55: 2280812
|
56 |
+
Case #56: 187946
|
57 |
+
Case #57: 763312
|
58 |
+
Case #58: 195522
|
59 |
+
Case #59: 61141
|
60 |
+
Case #60: 542559
|
61 |
+
Case #61: 867607
|
62 |
+
Case #62: 1190648
|
63 |
+
Case #63: 836738
|
64 |
+
Case #64: 1044902
|
65 |
+
Case #65: 208557
|
66 |
+
Case #66: 14697
|
67 |
+
Case #67: 64356
|
68 |
+
Case #68: 907868
|
69 |
+
Case #69: 321263
|
70 |
+
Case #70: 401231
|
71 |
+
Case #71: 1437409
|
72 |
+
Case #72: 2242791
|
73 |
+
Case #73: 1152983
|
74 |
+
Case #74: 153111
|
75 |
+
Case #75: 390411
|
76 |
+
Case #76: 873270
|
77 |
+
Case #77: 1038350
|
78 |
+
Case #78: 564961
|
79 |
+
Case #79: 1311058
|
80 |
+
Case #80: 2589986
|
81 |
+
Case #81: 714582
|
82 |
+
Case #82: 142655
|
83 |
+
Case #83: 589256
|
84 |
+
Case #84: 493366
|
85 |
+
Case #85: 1600348
|
86 |
+
Case #86: 807495
|
87 |
+
Case #87: 352127
|
88 |
+
Case #88: 930137
|
89 |
+
Case #89: 127024
|
90 |
+
Case #90: 2087426
|
91 |
+
Case #91: 320918
|
92 |
+
Case #92: 29704
|
93 |
+
Case #93: 1310383
|
94 |
+
Case #94: 361290
|
95 |
+
Case #95: 724433
|
96 |
+
Case #96: 2183450
|
97 |
+
Case #97: 1346130
|
98 |
+
Case #98: 1344370
|
99 |
+
Case #99: 18994
|
100 |
+
Case #100: 1054292
|
2015/round1/winning_at_sports.html
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p>
|
2 |
+
In the game of <em>Sports</em>, the object is have more points than the other
|
3 |
+
team after a certain amount of time has elapsed. Scores are denoted by
|
4 |
+
two hyphen-separated integers. For example, scores may include 3-2,
|
5 |
+
4-1, or 10-0. The first number is how many points you've scored, and the second
|
6 |
+
is the number of points scored by the opposing team. You're very good at
|
7 |
+
<em>Sports</em>, and consequently you always win. However, you don't always
|
8 |
+
achieve victory the same way every time.
|
9 |
+
</p>
|
10 |
+
|
11 |
+
<p>
|
12 |
+
The two most extreme kinds of victory are called <strong>stress-free</strong> and
|
13 |
+
<strong>stressful</strong>. In a <strong>stress-free</strong> victory, you score the first
|
14 |
+
point and from then on you always have more points than your opponent.
|
15 |
+
In a <strong>stressful</strong> victory, you never have more points than your opponent
|
16 |
+
until after their score is equal to their final score.
|
17 |
+
</p>
|
18 |
+
|
19 |
+
<p>
|
20 |
+
Given the final score of a game of <em>Sports</em>, how many ways could you
|
21 |
+
arrange the order in which the points are scored such that you secure a
|
22 |
+
<strong>stress-free</strong> or <strong>stressful</strong> win?
|
23 |
+
</p>
|
24 |
+
|
25 |
+
<h3>Input</h3>
|
26 |
+
|
27 |
+
<p>
|
28 |
+
Input begins with an integer <strong>T</strong>, the number of games
|
29 |
+
you'll play. For each game, there is one line containing the final score of
|
30 |
+
the game in the format described above.
|
31 |
+
</p>
|
32 |
+
|
33 |
+
|
34 |
+
<h3>Output</h3>
|
35 |
+
|
36 |
+
<p>
|
37 |
+
For the <strong>i</strong>th game, print a line containing "Case #<strong>i</strong>: "
|
38 |
+
followed by two space-separated integers, the number
|
39 |
+
of ways you can achieve a <strong>stress-free</strong> or <strong>stressful</strong> win,
|
40 |
+
respectively. Since these numbers may be very large, output them modulo
|
41 |
+
1,000,000,007.
|
42 |
+
</p>
|
43 |
+
|
44 |
+
|
45 |
+
<h3>Constraints</h3>
|
46 |
+
<p>
|
47 |
+
1 ≤ <strong>T</strong> ≤ 100 <br />
|
48 |
+
</p>
|
49 |
+
|
50 |
+
<p>
|
51 |
+
Since you always win, the first number in any final score
|
52 |
+
will always be larger than the second. Both scores will be non-negative
|
53 |
+
integers not exceeding 2000.
|
54 |
+
</p>
|
55 |
+
|
56 |
+
<h3>Explanation of Sample</h3>
|
57 |
+
<p>
|
58 |
+
In the third test case, you can get a stress-free win by scoring points 1, 2, and 4, or points 1, 2, and 3.
|
59 |
+
You can get a stressful win by scoring points 2, 4, and 5, or points 3, 4, and 5.
|
60 |
+
</p>
|
61 |
+
|
2015/round1/winning_at_sports.in
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
100
|
2 |
+
2-1
|
3 |
+
3-1
|
4 |
+
3-2
|
5 |
+
10-5
|
6 |
+
1000-500
|
7 |
+
1-0
|
8 |
+
2000-0
|
9 |
+
2000-1999
|
10 |
+
1549-221
|
11 |
+
1411-1215
|
12 |
+
1930-850
|
13 |
+
1582-971
|
14 |
+
1446-363
|
15 |
+
703-149
|
16 |
+
1999-474
|
17 |
+
444-264
|
18 |
+
1500-481
|
19 |
+
1919-408
|
20 |
+
1244-1138
|
21 |
+
614-116
|
22 |
+
1872-1535
|
23 |
+
1925-491
|
24 |
+
877-785
|
25 |
+
1978-1744
|
26 |
+
1014-220
|
27 |
+
708-604
|
28 |
+
1215-1102
|
29 |
+
1966-452
|
30 |
+
1506-184
|
31 |
+
647-313
|
32 |
+
1302-883
|
33 |
+
1940-1927
|
34 |
+
862-610
|
35 |
+
1571-1533
|
36 |
+
1831-127
|
37 |
+
1700-1584
|
38 |
+
827-274
|
39 |
+
955-524
|
40 |
+
712-139
|
41 |
+
1641-953
|
42 |
+
1677-214
|
43 |
+
1055-365
|
44 |
+
1423-1321
|
45 |
+
669-71
|
46 |
+
1581-1315
|
47 |
+
1335-110
|
48 |
+
1537-888
|
49 |
+
764-52
|
50 |
+
1443-800
|
51 |
+
1130-27
|
52 |
+
1542-469
|
53 |
+
1919-37
|
54 |
+
1221-300
|
55 |
+
1486-1125
|
56 |
+
1117-354
|
57 |
+
1791-496
|
58 |
+
1363-931
|
59 |
+
782-400
|
60 |
+
1516-336
|
61 |
+
1841-1045
|
62 |
+
649-312
|
63 |
+
1208-194
|
64 |
+
1013-706
|
65 |
+
532-4
|
66 |
+
1580-1168
|
67 |
+
1284-602
|
68 |
+
174-152
|
69 |
+
609-283
|
70 |
+
1009-912
|
71 |
+
1096-301
|
72 |
+
980-850
|
73 |
+
1958-1427
|
74 |
+
1531-534
|
75 |
+
562-165
|
76 |
+
1857-1673
|
77 |
+
1669-369
|
78 |
+
1598-929
|
79 |
+
135-73
|
80 |
+
1210-866
|
81 |
+
1192-147
|
82 |
+
1636-53
|
83 |
+
481-191
|
84 |
+
1693-925
|
85 |
+
1999-1592
|
86 |
+
1159-249
|
87 |
+
1286-709
|
88 |
+
1488-1484
|
89 |
+
1361-28
|
90 |
+
670-484
|
91 |
+
769-295
|
92 |
+
565-220
|
93 |
+
740-160
|
94 |
+
1563-737
|
95 |
+
873-295
|
96 |
+
1254-478
|
97 |
+
1725-736
|
98 |
+
543-371
|
99 |
+
1551-1296
|
100 |
+
461-263
|
101 |
+
853-800
|
2015/round1/winning_at_sports.md
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
In the game of _Sports_, the object is have more points than the other team
|
2 |
+
after a certain amount of time has elapsed. Scores are denoted by two hyphen-
|
3 |
+
separated integers. For example, scores may include 3-2, 4-1, or 10-0. The
|
4 |
+
first number is how many points you've scored, and the second is the number of
|
5 |
+
points scored by the opposing team. You're very good at _Sports_, and
|
6 |
+
consequently you always win. However, you don't always achieve victory the
|
7 |
+
same way every time.
|
8 |
+
|
9 |
+
The two most extreme kinds of victory are called **stress-free** and
|
10 |
+
**stressful**. In a **stress-free** victory, you score the first point and
|
11 |
+
from then on you always have more points than your opponent. In a
|
12 |
+
**stressful** victory, you never have more points than your opponent until
|
13 |
+
after their score is equal to their final score.
|
14 |
+
|
15 |
+
Given the final score of a game of _Sports_, how many ways could you arrange
|
16 |
+
the order in which the points are scored such that you secure a **stress-
|
17 |
+
free** or **stressful** win?
|
18 |
+
|
19 |
+
### Input
|
20 |
+
|
21 |
+
Input begins with an integer **T**, the number of games you'll play. For each
|
22 |
+
game, there is one line containing the final score of the game in the format
|
23 |
+
described above.
|
24 |
+
|
25 |
+
### Output
|
26 |
+
|
27 |
+
For the **i**th game, print a line containing "Case #**i**: " followed by two
|
28 |
+
space-separated integers, the number of ways you can achieve a **stress-free**
|
29 |
+
or **stressful** win, respectively. Since these numbers may be very large,
|
30 |
+
output them modulo 1,000,000,007.
|
31 |
+
|
32 |
+
### Constraints
|
33 |
+
|
34 |
+
1 ≤ **T** ≤ 100
|
35 |
+
|
36 |
+
Since you always win, the first number in any final score will always be
|
37 |
+
larger than the second. Both scores will be non-negative integers not
|
38 |
+
exceeding 2000.
|
39 |
+
|
40 |
+
### Explanation of Sample
|
41 |
+
|
42 |
+
In the third test case, you can get a stress-free win by scoring points 1, 2,
|
43 |
+
and 4, or points 1, 2, and 3. You can get a stressful win by scoring points 2,
|
44 |
+
4, and 5, or points 3, 4, and 5.
|
45 |
+
|
2015/round1/winning_at_sports.out
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Case #1: 1 1
|
2 |
+
Case #2: 2 1
|
3 |
+
Case #3: 2 2
|
4 |
+
Case #4: 1001 42
|
5 |
+
Case #5: 70047606 591137401
|
6 |
+
Case #6: 1 1
|
7 |
+
Case #7: 1 1
|
8 |
+
Case #8: 319838403 319838403
|
9 |
+
Case #9: 407599208 416582650
|
10 |
+
Case #10: 931707689 601702223
|
11 |
+
Case #11: 617690761 720720066
|
12 |
+
Case #12: 837137729 227376481
|
13 |
+
Case #13: 824539579 949882401
|
14 |
+
Case #14: 633156245 354441979
|
15 |
+
Case #15: 116188991 469122262
|
16 |
+
Case #16: 558565127 312949408
|
17 |
+
Case #17: 424855816 964380814
|
18 |
+
Case #18: 678762874 810834988
|
19 |
+
Case #19: 944478903 247049988
|
20 |
+
Case #20: 679221065 901403157
|
21 |
+
Case #21: 568451865 402056534
|
22 |
+
Case #22: 424370264 960630947
|
23 |
+
Case #23: 715062585 794279542
|
24 |
+
Case #24: 149556166 176349646
|
25 |
+
Case #25: 407453334 785126250
|
26 |
+
Case #26: 264377506 533391397
|
27 |
+
Case #27: 788649722 763674423
|
28 |
+
Case #28: 143957840 638571138
|
29 |
+
Case #29: 885201846 81012050
|
30 |
+
Case #30: 9814502 808219050
|
31 |
+
Case #31: 128185490 648087915
|
32 |
+
Case #32: 370665806 539919518
|
33 |
+
Case #33: 109667929 662611179
|
34 |
+
Case #34: 328184308 627650788
|
35 |
+
Case #35: 603377488 631844581
|
36 |
+
Case #36: 992276375 336710496
|
37 |
+
Case #37: 56103256 467176030
|
38 |
+
Case #38: 452477938 341584130
|
39 |
+
Case #39: 704322164 767415875
|
40 |
+
Case #40: 326766250 712856433
|
41 |
+
Case #41: 513721593 19870649
|
42 |
+
Case #42: 940446741 464107227
|
43 |
+
Case #43: 299357201 465463045
|
44 |
+
Case #44: 918270667 185042843
|
45 |
+
Case #45: 133432101 839838061
|
46 |
+
Case #46: 14099157 687851011
|
47 |
+
Case #47: 228180963 73438287
|
48 |
+
Case #48: 942083314 323205961
|
49 |
+
Case #49: 816502871 4028078
|
50 |
+
Case #50: 696316964 550429273
|
51 |
+
Case #51: 65627243 455845943
|
52 |
+
Case #52: 886784720 966114350
|
53 |
+
Case #53: 616614881 718512182
|
54 |
+
Case #54: 838827309 74747751
|
55 |
+
Case #55: 616119039 957096711
|
56 |
+
Case #56: 763445604 37769293
|
57 |
+
Case #57: 914446682 326487736
|
58 |
+
Case #58: 640809903 497153305
|
59 |
+
Case #59: 758592999 530342463
|
60 |
+
Case #60: 483725318 646137453
|
61 |
+
Case #61: 285278399 723024629
|
62 |
+
Case #62: 16605071 73744548
|
63 |
+
Case #63: 927054563 881639757
|
64 |
+
Case #64: 350000919 14
|
65 |
+
Case #65: 275736028 844497257
|
66 |
+
Case #66: 380983406 319827269
|
67 |
+
Case #67: 250782506 49035108
|
68 |
+
Case #68: 858463859 925866024
|
69 |
+
Case #69: 128635484 500668215
|
70 |
+
Case #70: 410450602 18714029
|
71 |
+
Case #71: 238405893 720720066
|
72 |
+
Case #72: 23789578 923029325
|
73 |
+
Case #73: 507059447 741860141
|
74 |
+
Case #74: 428961024 264105011
|
75 |
+
Case #75: 254458120 204820879
|
76 |
+
Case #76: 798717050 797874213
|
77 |
+
Case #77: 658595747 24605944
|
78 |
+
Case #78: 330170277 458247558
|
79 |
+
Case #79: 150263723 650437050
|
80 |
+
Case #80: 216067901 112571416
|
81 |
+
Case #81: 65720917 812467623
|
82 |
+
Case #82: 460115761 208324196
|
83 |
+
Case #83: 910296350 834019692
|
84 |
+
Case #84: 128284947 22214272
|
85 |
+
Case #85: 839667341 31578719
|
86 |
+
Case #86: 568486330 666795455
|
87 |
+
Case #87: 689903668 992420028
|
88 |
+
Case #88: 914956340 949904131
|
89 |
+
Case #89: 997814136 441095159
|
90 |
+
Case #90: 304284048 947787397
|
91 |
+
Case #91: 896508018 785126250
|
92 |
+
Case #92: 794540851 361798437
|
93 |
+
Case #93: 885842866 220639770
|
94 |
+
Case #94: 132989766 947787397
|
95 |
+
Case #95: 199657043 899965082
|
96 |
+
Case #96: 622770288 707003450
|
97 |
+
Case #97: 165622659 835003284
|
98 |
+
Case #98: 225795326 523210601
|
99 |
+
Case #99: 612020853 406955973
|
100 |
+
Case #100: 694658552 4028078
|
2015/round2/all_critical.html
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p>
|
2 |
+
In the game <em>Theatrhythm Final Fantasy</em>, you poke a screen with a stick
|
3 |
+
to the beat of various songs. The goal is to poke the screen as accurately as
|
4 |
+
possible. If you hit a note at just the right time, you're awarded a
|
5 |
+
<strong>critical</strong>. Every song is broken into 20 sections, and if you get a
|
6 |
+
<strong>critical</strong> on every note in a section, then you get that section's
|
7 |
+
golden <strong>critical bar</strong>.
|
8 |
+
</p>
|
9 |
+
|
10 |
+
|
11 |
+
<p>
|
12 |
+
You would like to collect all 20 <strong>critical bars</strong> for every song.
|
13 |
+
Songs vary in difficulty, but each song has a fixed probability <strong>p</strong>, which
|
14 |
+
is the chance that you manage to secure any one <strong>critical bar</strong>
|
15 |
+
on a single playthrough.
|
16 |
+
The chances are independent, so for any given pair of sections, the probability of
|
17 |
+
getting both <strong>critical bars</strong> in a single playthrough is <strong>p</strong><sup>2</sup>, and so on.
|
18 |
+
<strong>Critical bars</strong> are saved between playthroughs, so you don't have to win
|
19 |
+
all of the <strong>critical bars</strong> in a single play of the song. You might win
|
20 |
+
the first 10 on one play, and then the last 10 on another.
|
21 |
+
</p>
|
22 |
+
|
23 |
+
<p>
|
24 |
+
On average, how many times will you have to play a song to win all 20
|
25 |
+
<strong>critical bars</strong>?
|
26 |
+
</p>
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
<h3>Input</h3>
|
31 |
+
|
32 |
+
<p>
|
33 |
+
Input begins with an integer <strong>T</strong>, the number of songs
|
34 |
+
you'll play. For each song, there is a line containing a floating point number,
|
35 |
+
<strong>p</strong>, the probability of winning any particular
|
36 |
+
<strong>critical bar</strong> on a single play of the song.
|
37 |
+
</p>
|
38 |
+
|
39 |
+
<h3>Output</h3>
|
40 |
+
|
41 |
+
<p>
|
42 |
+
For each song, output the expected number of times you need to play the song
|
43 |
+
before acquiring all 20 <strong>critical bars</strong>, rounded to five decimal points.
|
44 |
+
</p>
|
45 |
+
|
46 |
+
<p>
|
47 |
+
Absolute errors of up to 10<sup>-5</sup> will be ignored.
|
48 |
+
</p>
|
49 |
+
|
50 |
+
<h3>Constraints</h3>
|
51 |
+
<p>
|
52 |
+
1 ≤ <strong>T</strong> ≤ 20 <br />
|
53 |
+
0.01 ≤ <strong>p</strong> ≤ 1.0 <br />
|
54 |
+
</p>
|
55 |
+
|
56 |
+
|
57 |
+
|