#QHD0000024. Tính toán trong chương trình truyền hình (Game Show Math)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Tính toán trong chương trình truyền hình (Game Show Math)
Game Show Math
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
A game show provides positive integers in fixed order and a target . Insert exactly one operator from +, -, *, / between each pair of adjacent numbers to obtain .
Evaluate operations strictly from left to right, ignoring the usual multiplication and division precedence. Division must be exact. After each operation, the intermediate result must stay within . The numbers may not be reordered.
Print any valid expression, or NO EXPRESSION if no expression exists.
Input
The first line contains .
The second line contains the positive integers in their fixed order.
The third line contains target integer .
Output
Print any valid expression without spaces using the input numbers in order, with operators between them and =T at the end. Print NO EXPRESSION if impossible.
Subtasks
- Subtask 1 (20 points): ; ; ; Intermediate results must lie within ; division must be exact.
- Subtask 2 (30 points): ; ; ; Intermediate results must lie within ; division must be exact.
- Subtask 3 (50 points): ; ; ; Intermediate results must lie within ; division must be exact.
Examples
Input
3
5 7 4
3
Output
5+7/4=3
Explanation
Evaluate 5+7/4=3 from left to right, without the usual precedence rules. First , then . Division is exact and both intermediate values are in range.