Professional Documents
Culture Documents
Acm Icpc Bicol2013 Problemset Final
Acm Icpc Bicol2013 Problemset Final
Acm Icpc Bicol2013 Problemset Final
+ Cx + + , -
."e tas# is %uite complicated especially if one solution is irrational. *efore you complained, !anna"
told you t"at s"e/ll only 'ive cu$ic e%uations &it" at least one inte'er solution.
0our tas# t"en is to find all distinct real solutions of t"e cu$ic e%uation 'iven t"e coefficients (, *, C,
and + &"ere ( is not -.
."e ran'e of values of (, *, C, and + is 1,---,--- to ,---,---. ."e ran'e of values of x is
12,---,--- to 2,---,---.
INPUT FORMAT
."e input starts &it" an inte'er N (&"ere - 3 N 3 2--). It is t"en follo&ed $y N input lines. Eac" input
line consists of four num$ers (, *, C, and +, not necessarily inte'ers. ( is never -.
OUTPUT FORMAT
4or eac" input line, print all distinct real solutions of t"e cu$ic e%uation in one line, sorted in increasin'
order. Eac" real solution must $e rounded off to t"e nearest ten t"ousandt" and must $e printed &it"
exactly four di'its after t"e decimal point. .&o or more distinct real solutions must $e separated $y
exactly one space.
SAMPLE INPUT
3
1.5 -5 2 -1.5
2 -7 7 -2
2 0 0 0
SAMPLE OUTPUT
3.0000
0.5000 1.0000 2.0000
0.0000
55
Copyri'"t 6 -2), (llan Sioson and (C7 IC8C 8"ilippines 7ulti18rovincial 8ro'rammin' Contest
ACM ICPC Problem 3
Problem D: Multiplication in a Dihedral Group
Input from file: pd.in
Output to console: stdout (in C), cout (in C++), System.out (in Java)
Execution time limit: seconds
! di"edral #roup is a set $ %it" a multiplication operation & defined on $. '"e set $ is #enerated (y
t%o elements a and (. '"e multiplication operation & %ill not (e explicitly %ritten, so t"at a&a %ill (e
indicated (y aa or (y a
)
. Similarly, a&a&( %ill (e indicated (y a
)
(
*
or simply a
)
(.
'"e di"edral #roup $ "as t%o inte#er parameters m and n, %it" m + ) and n + ), and so %e %rite t"e
di"edral #roup as $
m,n
. '"e relations t"at define $
m,n
are:
a
m
, a
-
, *, (
n
, (
-
, *, and (a , a
(m.*)
(.
'"us $
m,n
"as (mn) elements, namely
$
m,n
, / a
0
(
1
2 - 3 0 4 m, - 3 1 4 n 5 , / a
-
(
-
, a
*
(
-
, a
)
(
-
, 6 , a
(m.*)
(
-
, . . . , a
(m.*)
(
(n.*)
5.
7or example, select m , 8 and n , ). '"e elements of $
8,)
are
/ a
-
(
-
, a
*
(
-
, a
)
(
-
, a
9
(
-
, a
:
(
-
, a
(
-
, a
;
(
-
, a
-
(
*
, a
*
(
*
, a
)
(
*
, a
9
(
*
, a
:
(
*
, a
(
*
, a
;
(
*
5.
<ultiplication is not commutative, and so (a = a(. In fact (a , a
;
(, accordin# to t"e definin# relations
of $
8,)
. !lso, a
0
a
1
, a
(0+1)>m
, and (
0
(
1
, (
(0+1)>n
. '"us
(a
0
(
1
)(a
p
(
?
) = (a
(0+p)>m
(
(1+?)>n
).
'o properly multiply t"e t%o elements (a
9
(
*
) and (a
)
(
*
) of $
8,)
, %e proceed as follo%s,
(a
9
(
*
)(a
)
(
*
) , (a
9
(
-
)((a)(a
*
(
*
) , (a
9
(
-
)(a
;
(
*
)(a
*
(
*
),
since (a , a
;
(.
!lso, since a
9
(
-
a
;
, a
9
a
;
, a
(9+;)>8
, a
)
, %e can multiply t"e first t%o factors and #et (a
9
(
-
)(a
;
(
*
) , (a
)
(
*
).
'"us
(a
9
(
-
)(a
;
(
*
)(a
*
(
*
) , (a
)
(
*
)(a
*
(
*
).
@o% %e can re%rite t"is as follo%s,
(a
)
(
*
)(a
*
(
*
) , (a
)
(
-
)((a)(a
-
(
*
) , (a
)
(
-
)(a
;
(
*
)(a
-
(
*
) , (a
A
(
)
) , (a
*
(
-
).
'"us, multiplyin# t"e t%o elements (a
9
(
*
) and (a
)
(
*
) #ives, (a
9
(
*
)(a
)
(
*
) , (a
*
(
-
).
4 ACM ICPC Problem
Bour pro(lem is to %rite a computer pro#ram, #iven m, n, and any t%o elements (a
0
(
1
) and (a
p
(
?
) of t"e
di"edral #roup $
m,n
t"at computes t"e correct product of t"e t%o.
INPUT FORMAT
'"e input consists of several pro(lem sets. Eac" pro(lem set consists of several lines of input. '"e first
line %ill contain t"e pro(lemI$, m, n, and p, separated (y spaces. '"e inte#ers m and n %ill not exceed
*--- in value. '"e num(er p is t"e num(er of multiplication pro(lems for t"is pro(lem set. '"e first
line is follo%ed (y p lines of input, eac" line containin# t%o elements of $
m,n
to multiply. Eac" element
%ill (e #iven in t"e form a9(* instead of a
9
(
*
. $ata for t"e next pro(lem set %ill immediately follo%
t"e previous pro(lem set. ! set pro(lemI$ of CZZD %ill indicate end of input.
OUTPUT FORMAT
7or eac" multiplication pro(lem, print one line of t"e form
ProblemID id: aj(k & ap(q = ar(s
%"ere id is t"e pro(lemI$ #iven in t"e input, aj(k and ap(q are t"e elements to multiply, and ar(s is
t"e correct ans%er.
SAMPL INPUT
C1 7 2 3
a3b1 a2b1
a5b1 a3b1
a2b1 a4b1
C2 9 3 2
a3b1 a2b1
a4b1 a3b1
ZZ 0 0 0
SAMPL OUTPUT
ProblemID C1: a3b1 * a2b1 = a1b0
ProblemID C1: a5b1 * a3b1 = a2b0
ProblemID C1: a2b1 * a4b1 = a5b0
ProblemID C2: a3b1 * a2b1 = a1b2
ProblemID C2: a4b1 * a3b1 = a1b2
EE
Copyri#"t F )-*9, Ga(lo <analastas and !C< ICGC G"ilippines <ulti.Grovincial Gro#rammin# Contest
ACM ICPC Problem 5
Problem E: Area Between Outer Hull and Inner Hull
Input from file: pe.in
Output to console: stdout (in C), cout (in C++), System.out (in Java)
Execution time limit: seconds
!iven a set S of N points on t"e plane, namely S # $(x%&', y%&'), (x%(', y%('), ... , (x%N)(', y%N)(')*, t"e
outer hull +o of S is simply ,ust t"e convex "ull of S. It is a su-set of points of S ."ic" ."en ,oined -y
line se/ments .ill form a convex poly/on P of minimum area t"at includes all points of S inside P or
on P. 0oints of S fallin/ on P -ut are not corner vertices of P are not considered part of t"e convex "ull.
1"e inner hull +i of S is o-tained -y /ettin/ t"e convex "ull of S 2 +o. 1"at is, remove from set S all
points t"at -elon/ to t"e outer "ull +o, to /et t"e set (S 2 +o). 1"en compute t"e inner "ull +i as t"e
convex "ull of (S 2 +o).
3or example /iven t"e set S of 4 points 5(6.&, .&), 7(6.&, 8.&),
C(6.&, 6.&), 9((.&, (.&), E(8.&, (.&), 3(&.&, &.&), !(:.&, &.&), and
+(.&, &.&), t"e outer "ull +o of S can -e computed as t"e set
+o#$3, +, 5, 3*. If .e remove +o from S, .e /et S 2 +o # $7, C,
9, E, !*. 1"e inner "ull +i of S is computed as t"e convex "ull of
S 2 +o, namely +i # $9, !, E, 7, 9*. ;o. t"e area inside +o is
area(+o) # (6.. 1"e area inside +i is area(+i) # <.&. 1"us t"e area
-et.een t"e outer "ull +o and t"e inner "ull +i is (6. 2 <.& # <..
=our pro-lem is, /iven a set S of N points, to .rite a pro/ram t"at
computes t"e area -et.een t"e outer "ull +o of S, and t"e inner "ull
+i of S.
INPUT FORMAT
1"e input consists of several pro-lem sets. 1"e first line of a pro-lem set .ill contain t"e pro-lemI9
and t"e value of N. 1"e value of N .ill not exceed (,&&&. 1"e next N lines of t"e pro-lem set .ill
contain t"e value of x) and y)coordinate (separated -y a space) of a point, at one point per line. Eac"
coordinate x or y .ill -e a real num-er not exceedin/ (&&.& in a-solute value. 1"e lines of t"e next
pro-lem set .ill immediately follo. t"e previous pro-lem set. 5 line .it" pro-lemI9 of >ZZ? and a
value of N of & indicates t"e end of input.
OUTPUT FORMAT
3or eac" pro-lem set, print one line of t"e form >ProblemID id: area? ."ere id is t"e pro-lemI9 /iven
in t"e input, and area is t"e area -et.een t"e outer "ull +o and t"e inner "ull +i t"at you computed.
Express t"e area .it" 8 decimal places.
See sample input and corresponding output on the next page.
6 ACM ICPC Problem
SAMPLE INPUT
A1 8
2.0 5.0
2.0 4.0
2.0 2.0
1.0 1.0
4.0 1.0
0.0 0.0
3.0 0.0
5.0 0.0
A2 11
1.0 5.0
5.0 5.0
2.0 4.0
3.0 4.0
2.0 3.0
2.0 2.0
3.0 2.0
1.0 1.0
4.0 1.0
0.0 0.0
4.0 0.0
ZZ 0
SAMPLE OUTPUT
ProblemID A1: 6.5000
ProblemID A2: 14.0000
@@
Copyri/"t A 6&(:, 0a-lo Banalastas and 5CB IC0C 0"ilippines Bulti)0rovincial 0ro/rammin/ Contest
ACM ICPC Problem 7
Problem F: Sharkovskis Ordering
Input from file: pf.in
Output to console: stdout (in C), cout (in C++), System.out (in Java)
Execution time limit: seconds
In a !"#$ paper on continuous mappin%s of t&e reals into t&e reals, 'lexandr S&ar(ovs(i used t&e
follo)in% orderin% of t&e positive inte%ers:
* + , + - + " + ... + *. + ,. + -. + ... + *.
+ ,.
+ ... +
*
+
+ + !
's Ciesiels(i and /o%oda (001) descri2e it:
34irst come t&e odd num2ers, 2e%innin% )it& *, arran%ed in increasin% order. 5&is se6uence is
repeated )it& eac& odd inte%er multiplied 2y . 5&e initial se6uence is a%ain repeated )it& eac& odd
inte%er multiplied 2y