Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
Language:
Formatting function
Time Limit: 2000MSMemory Limit: 65536K
Total Submissions: 2353Accepted: 339

Description

Text formatting functions (Format, sprintf, etc) are very common between programming languages. Your task is to implement a simplified one.

Formatting function receives format string and several arguments. Argument values are processed one by one and inserted into format string at positions designated by format specifiers. The following format specifiers must be implemented:

* %s — argument as a string
* %d — argument as an integer value, without any leading zeroes
* %% — literal '%' character

Formatting error is generated if:

* number of arguments required by format specifiers is not equal to the number of actually supplied arguments,
* argument for %d specifier contains non-digit character.
* '%' character in format string is not followed by either '%', 's' or 'd'.

Input

Input file contains format string followed by arguments, one per line.

Constraints

Number of arguments is not greater than 1000, length of each line is not greater than 50000 characters.

Output

Output file must contain a single string — either formatted text or ERROR in case of any formatting error.

Sample Input

Sample Input 1
%d x %d %s %d
2
02
=
4
Sample Input 2
%s
Sample Input 3
%d
2a

Sample Output

Sample Output 1
2 x 2 = 4
Sample Output 2
ERROR
Sample Output 3
ERROR

Hint

Bold texts appearing in the sample sections are informative and do not form part of the actual data.

Source

Northeastern Europe 2006, Far-Eastern Subregion

[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator