Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
pdp-camp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Public
pdp-camp
Commits
18eafc36
Commit
18eafc36
authored
Apr 08, 2014
by
Nikolaos S. Papaspyrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add material for 2014 (day 1, mostly junior)
parent
38910a0c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
0 deletions
+75
-0
242b.cpp
2014/242b.cpp
+43
-0
281b.cpp
2014/281b.cpp
+32
-0
Trees.pdf
2014/Trees.pdf
+0
-0
No files found.
2014/242b.cpp
0 → 100644
View file @
18eafc36
#include <cstdio>
#include <cmath>
#include <cfloat>
using
namespace
std
;
int
main
()
{
#ifdef CONTEST
freopen
(
"242b.in"
,
"rt"
,
stdin
);
freopen
(
"242b.out"
,
"wt"
,
stdout
);
#endif
int
n
;
scanf
(
"%d"
,
&
n
);
int
a
[
n
],
b
[
n
];
int
min_a
=
0
,
max_b
=
0
;
int
best_i
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
scanf
(
"%d %d"
,
&
a
[
i
],
&
b
[
i
]);
if
(
max_b
-
min_a
<=
b
[
i
]
-
a
[
i
])
{
max_b
=
b
[
i
];
min_a
=
a
[
i
];
best_i
=
i
+
1
;
}
}
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
if
(
a
[
i
]
<
min_a
||
b
[
i
]
>
max_b
)
{
printf
(
"-1
\n
"
);
return
0
;
}
}
printf
(
"%d
\n
"
,
best_i
);
return
0
;
}
2014/281b.cpp
0 → 100644
View file @
18eafc36
#include <cstdio>
#include <cmath>
#include <cfloat>
using
namespace
std
;
int
main
()
{
#ifdef CONTEST
freopen
(
"281b.in"
,
"rt"
,
stdin
);
freopen
(
"281b.out"
,
"wt"
,
stdout
);
#endif
int
x
,
y
,
n
;
scanf
(
"%d %d %d"
,
&
x
,
&
y
,
&
n
);
double
min_d
=
DBL_MAX
;
// +infinity
int
best_a
,
best_b
;
for
(
int
b
=
1
;
b
<=
n
;
b
++
)
{
int
a
=
(
int
)
ceil
((
double
)
b
*
x
/
y
-
0.5
);
double
d
=
fabs
((
double
)
x
/
y
-
(
double
)
a
/
b
);
if
(
d
<
min_d
)
{
min_d
=
d
;
best_a
=
a
;
best_b
=
b
;
}
}
printf
(
"%d/%d
\n
"
,
best_a
,
best_b
);
return
0
;
}
2014/Trees.pdf
0 → 100644
View file @
18eafc36
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment