Author: | A. Baranov | Time limit: | 1 sec | |
Input file: | input.txt | Memory limit: | 256 Mb | |
Output file: | output.txt |
Your program must calculate total number of such pairs of integers (p, n) that p ≥ 1, n > 1 и A ≤ pn ≤ B.
Input file contains two integers A and B.
Output file must contain a single integer — number of pairs.
2 ≤ A ≤ B < 263
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|
Author: | I. Tuphanov | Time limit: | 1 sec | |
Input file: | input.txt | Memory limit: | 256 Mb | |
Output file: | output.txt |
Young marine biologist Masha spent her summer in Primorye, diving and taking notes of what she saw on the seafloor. Later she found her records for one of the bays where she has been. These records were:
Help Masha to figure the minimum possible percentage of the seafloor inhabited by all three species simultaneously.
In the first example, shellfish live everywhere. Starfish and sea urchins each take 3/4 of the seafloor, which means that at least half of the seafloor is inhabited by shellfish, starfish and sea urchins simultaneously.
In the second example, there are areas where 2 out of 3 species live. But it's possible that there are no areas where all 3 species live.
Input file contains integers A, B and C.
Output file must contain a single integer from 0 to 100 — the answer, in percents.
0 ≤ A, B, C ≤ 100
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
Author: | A. Klenin, M. Sporyshev | Time limit: | 1 sec | |
Input file: | input.txt | Memory limit: | 256 Mb | |
Output file: | output.txt |
Young programmer Vasya tinkered with robots, and decided to create a new startup Easy Patrol with the goal of producing robot guardian to replace human guards.
As a first step, he considered a single wall of N meters in length and two patrolling robots moving back and forth along it.
First robot starts patrolling at the point located x meters from the left edge of the wall, moving to the right. Second robot starts patrolling at the point located y meters from the left edge of the wall, moving to the left.
Each second, events happen in the following order:
Your program must determine maximum possible distance between two robots.
Input file contains integers N, x, y.
Output file must contain a single integer — maximum distance between robots in meters.
4 ≤ N ≤ 106
0 ≤ x, y ≤ N
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|
Author: | A. Baranov | Time limit: | 1 sec | |
Input file: | input.txt | Memory limit: | 256 Mb | |
Output file: | output.txt |
Consider a set of n points on a plane, described by their coordinates: M = {(xi, yi): i = 0, 1, …, n − 1}.
Your program must, given two points A and B, find a point C from set M, such that triangle {A, B, C} contains maximum possible number of points from M. Points both inside and on the edges of the triangle are counted.
Input file contains integer n, followed by n pairs of integers — point coordinates (xi, yi). Next, four integers follow — coordinates of points A and B.
Output file must contain a single integer — index of point C. Indexes start from zero. If there are several solutions, output any of them.
Points A and B are different.
− 104 ≤ (xi, yi) ≤ 104, 0 < n ≤ 105
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|
Author: | M. Sporyshev | Time limit: | 1 sec | |
Input file: | input.txt | Memory limit: | 256 Mb | |
Output file: | output.txt |
Young programmer Vasya lives in a city where streets can be represented by a tree. Each vertex of a tree correspond to an intersection, each edge — to a street. So number of streets in the city is 1 less than a number of intersections. It is possible to get from from each intersection to every other one by streets.
There are two kinds of streets — residential and office ones.
City administration wants to create a looping road, represented by a cycle of streets. To minimize spending, only a single road of either kind must be built, creating a cycle. To satisfy zoning regulations, cycle must consist of at least 4 streets and number of residential streets in the cycle must be equal to the number of office streets.
Young programmer Vasya is preparing a presentation for city mayor and wants to add a slide with the total number of ways to add a street to the city road system, while satisfying all requirements. Your program must calculate that number.
Input file contains integer N — number of intersections in the city, followed by N − 1 triplets of integers u, v, c — numbers of intersections connected by street (u, v) and the kind of the street. c = 0 — residential street, c = 1 — office street.
Output file must contain a single integer — number of ways.
3 ≤ N ≤ 3000
0 ≤ u, v < N
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|
Author: | A. Usmanov | Time limit: | 1 sec | |
Input / output: | interactive | Memory limit: | 256 Mb |
This is an interactive problem.
Jury has chosen a secret integer X consisting of exactly N bits. It is known that the number contains K bits '1' and N − K bits '0'. Your program can make queries of the form "+ Y", which causes current value of X to be increased by integer Y. Bits higher than N-th are truncated, so actual operation is X = (X + Y) mod 2N.
Jury's program answers every query with number of '1' bits in the current value of X. Your program must determine current value of X by making no more than ⌊ N2⌋ queries.
First line of input contains two integers N and K — total number of bits in the value and number of '1' bits in the starting value.
To make a query, your program must output "+ Y
",
where Y — integer to be added to X.
For every query jury's program will reply with a single integer —
number of '1' bits in the value of X after executing the request.
When your program determines current value of X, it must output "! X
"
and stop.
If your program will make incorrect query, it will receive "Presentation error" verdict. If your program will exceed allowed number of queries, it will receive "Wrong answer" verdict.
Every query and final output must be a single line ending with single end-of-line (\n
).
Output buffers must be flushed after every line:
Language | C++ | Pascal | Java | Python |
Code | cout.flush() |
flush(output) |
System.out.flush() |
stdout.flush() |
1 ≤ N ≤ 60
0 ≤ K ≤ N
0 ≤ X, Y < 2N
In the first sample jury has chosen number 13 (1101 in binary). After the first query the value is (13 + 9) mod 16 = 6 (01102). After the second query the value is (6 + 9) mod 16 = 15 (11112).
No. | Standard input | Standard output |
---|---|---|
1 |
|
|
2 |
|
|
Author: | A. Klenin | Time limit: | 1 sec | |
Input file: | input.txt | Memory limit: | 256 Mb | |
Output file: | output.txt |
Rectangular jigsaw puzzle consists of two pieces.
Each piece is a 4-connected set of square cells,
each cell represented by character 'X
' or 'O
'.
Your program must determine whether it is possible to separate puzzle pieces by moving either of them in vertical or horizontal direction.
In the first sample it is possible to separate pieces
by moving 'X
' piece up and/or 'O
' piece down.
First line of input contains two integers W H. Following H lines contain W characters each — puzzle representation.
Output must contain a single string YES
or NO
.
1 ≤ W, H ≤ 100. Each piece contains at least one cell.
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|