Time Limit: 2 sec / Memory Limit: 1024 MB
注意
この問題に対する言及は、2019年12月29日 05:00 JST まで禁止されています。言及がなされた場合、賠償が請求される可能性があります。
試験後に総合得点や認定級を公表するのは構いませんが、どの問題が解けたかなどの情報は発信しないようにお願いします。
問題文
あなたは、3 桁の整数を入力として受け取り、それを 2 倍して出力するプログラムの作成を頼まれた。
ところが、どうやらプログラムに入力される文字列 S に英小文字が紛れ込むことがあるようだ。そこで、その場合はエラーを出力することにした。
S が 3 桁の整数である場合 (0
で始まる場合を含む) はその 2 倍の値を出力し、そうでなければ error
と出力するプログラムを作成せよ。
制約
- S は長さ 3 の文字列である。
- S の各文字は数字または英小文字である。
入力
入力は以下の形式で標準入力から与えられる。
S
出力
問題文で指示された通りに整数または文字列 error
を出力せよ。
入力例 1
678
出力例 1
1356
整数が与えられているので、その 2 倍の値を出力する。
入力例 2
abc
出力例 2
error
整数でないものが与えられているので、error
と出力する。
入力例 3
0x8
出力例 3
error
数字と英小文字が混ざって与えられる場合もある。また、言語によっては整数として解釈可能な文字列であっても、error
と出力する。
入力例 4
012
出力例 4
24
S が 0
から始まる場合も、 10 進数の整数として扱うことに注意せよ。
Warning
Do not make any mention of this problem until December 29, 2019, 05:00 a.m. JST. In case of violation, compensation may be demanded.
After the examination, you can reveal your total score and grade to others, but nothing more (for example, which problems you solved).
Problem Statement
You were asked to write a program that receives a three-digit integer, multiplies it by 2, and prints the result.
It seems, however, that the string S given to the program may contain lowercase English letters. You decide to print an error message in such a case.
Write the following program: if S is a three-digit integer (possibly beginning with a 0
), the program should multiply it by 2 and print the result; otherwise, the program should print error
.
Constraints
- S is a string of length 3.
- Each character of S is a digit or a lowercase English letter.
Input
Input is given from Standard Input in the following format:
S
Output
Print an integer or a string error
, as specified in Problem Statement.
Sample Input 1
678
Sample Output 1
1356
For an integer, multiply it by 2 and print the result.
Sample Input 2
abc
Sample Output 2
error
For a non-integer string, print error
.
Sample Input 3
0x8
Sample Output 3
error
The input may be a combination of digits and English letters. Some languages can interpret these strings as integers, but print error
in these cases, too.
Sample Input 4
012
Sample Output 4
24
Assume that S is written in decimal notation, even if S begins with a 0
.