A - check digit Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 9

注意

この問題に対する言及は、2021/7/17 18:00 JST まで禁止されています。言及がなされた場合、賠償が請求される可能性があります。 試験後に総合得点や認定級を公表するのは構いませんが、どの問題が解けたかなどの情報は発信しないようにお願いします。

問題文

高橋君は、15 桁の数字で作られたコード S を発行しました。 S0, \ldots , 9 のみからなる、長さ 15 の文字列です。

この 15 桁のコードの、一番右の桁は、チェックディジットとなっており、残りの 14 桁から計算することが可能です。

まず、左の 14 桁のうち、左から奇数番目の数 (一番左の数を 1 番目と数えます) をすべて足し、その値を 3 倍します。 次に、こうして得られた値に、左から偶数番目の数をすべて足します。その値を 10 で割った余りが 15 桁目の数と一致するのが正しいコードで、一致しないのは正しくないコードです。

高橋君の代わりに、コード S が正しいかどうか判定するプログラムを作成してください。

制約

  • S の長さは 15
  • S0, \ldots , 9 のみからなる

入力

入力は以下の形式で標準入力から与えられる。

S

出力

コード S が正しい場合は Yes を、正しくない場合は No を出力せよ。


入力例 1

123451234512345

出力例 1

No

左の 14 桁のうち、奇数番目の数を足すと、1+3+5+2+4+1+3=19 です。これを 3 倍すると 57 です。

57 に偶数番目の数を足すと、57+2+4+1+3+5+2+4=78 となります。

7810 で割った余りは 8 であり、15 桁目である 5 と一致しません。


入力例 2

123451234512348

出力例 2

Yes

Score : 9 points

Warning

Do not make any mention of this problem until July 17, 2021, 6:00 p.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

Takahashi has issued a 15-digit code S, which is a string of length 15 consisting of 0, \ldots, 9.

The leftmost digit of this 15-digit code is a check digit, which can be computed from the other 14 digits.

To do this, we first find the sum of all odd-positioned digits in the first 14 digits, that is, the 1-st (leftmost), 3-rd, 5-th, \ldots, digits from the left, and multiply this sum by 3. To this multiplied value, we then add all even-positioned digits from the left in the code. Finally, we divide the result of these additions by 10, and if the remainder matches the 15-th digit, the code is valid; otherwise, the code is invalid.

Take Takahashi's place to write a program that determines whether the code S is valid.

Constraints

  • S has a length of 15.
  • S consists of 0, \ldots , 9.

Input

Input is given from Standard Input in the following format:

S

Output

If the code S is valid, print Yes; otherwise, print No.


Sample Input 1

123451234512345

Sample Output 1

No

The sum of all odd-positioned digits in the first 14 digits is 1+3+5+2+4+1+3=19, which will be 57 after multiplying by 3.

Adding all even-positioned digits to 57 results in 57+2+4+1+3+5+2+4=78.

The remainder when dividing 78 by 10 is 8, which does not match the 15-th digit: 5.


Sample Input 2

123451234512348

Sample Output 2

Yes