Author: | A. Zhuplev, A. Klenin | |||
Input file: | input.txt | Time limit: | 1 sec | |
Output file: | output.txt | Memory limit: | 256 Mb |
Underwater arithmetic is very elementary. There are just two operations: WITH and WITHOUT which mean addition and subtraction respectively.
Underwater mathematicians did not yet invent brackets, so all expressions are calculated from right to left. For example, the expression 3 WITH 5 WITHOUT 4 WITHOUT 7 is calculated as (3 + (5 − (4 − 7))).
Scientists of Nearsea Institute of Underwater Arithmetic need a program to evaluate such expressions.
First line of input file contains a single integer N. Following 2 × N + 1 lines describe the expression. Odd lines contain integer operands, even lines contain operations.
Output file must contain a single integer — calculation result.
1 ≤ N ≤ 103
All operands are in range from 0 to 103.
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|
Author: | I. Tuphanov | |||
Input file: | input.txt | Time limit: | 1 sec | |
Output file: | output.txt | Memory limit: | 256 Mb |
Young programmer Vasya is learning the beginnings of the algorithm complexity theory. For starters, he wants to be able to quickly estimate the number of iterations of nested loops. As a first example, he wrote the following code:
C | Pascal |
long long f(int n) { long long ans = 0; for (int i = 1; i <= n; i++) for (int j = i+1; j <= n; j++) for (int k = j+1; k <= n; k++) ans++; return ans; } |
function f(n: integer): int64; var i, j, k: integer; begin result := 0; for i := 1 to n do for j := i+1 to n do for k := j+1 to n do inc(result); end; |
Using your knowledge of the subject,
help Vasya calculate f(n)
for given n.
Input file contains an integer n.
Output file must contain a single integer — f(n)
.
1 ≤ n ≤ 106
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|
Author: | A. Zhuplev | |||
Input file: | input.txt | Time limit: | 1 sec | |
Output file: | output.txt | Memory limit: | 256 Mb |
According to ISO stadnard Metric tire code, tire dimensions are described by a string of letters and numbers in the following format:
Rules of ACM (Any Car Modification) race specify a fixed tire dimensions for all participating cars. Young racer Vasya has not been able to find this type of tire. However, his car will still be approved for the race by judges only if radius of the wheel (wheel disk radius plus sidewall height) differs by at most K percent from that of the specified tire.
Note: 1 inch = 25.4 millimeters. Number a differs from b by at most c percent when 100 × |a − b| / b ≤ c.
First line of input file contains integer K.
Second and third lines contain Metric tire codes of specified tire and Vasya's tire respectively. Tire codes contain only digits, R and slash (ASCII 47) characters.
Output file must contain a single string — APPROVED if Vasya's car is approved to the race or DISAPPROVED otherwise.
0 ≤ K ≤ 100
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|