#B4075. Determine if a Number is a Multiple of 11

    ID: 11732 Type: Default 1000ms 256MiB

Determine if a Number is a Multiple of 11

Determine if a Number is a Multiple of 11

Given a positive integer \(x\), your task is to determine whether \(x\) is a multiple of \(11\) using a digit sum method.

You can use a method similar to the one used for checking multiples of \(3\) as follows:

  • Let \(s_1\) be the sum of the digits in the ones, hundreds, ten-thousands, ... positions of \(x\).
  • Let \(s_2\) be the sum of the digits in the tens, thousands, hundred-thousands, ... positions of \(x\).

If \(s_1 \bmod 11 = s_2 \bmod 11\), then \(x\) is a multiple of \(11\). Otherwise, \(x\) is not a multiple of \(11\).

For example, consider \(x = 3162819\):

  • Digits at positions (from right): 9 (ones), 1 (tens), 8 (hundreds), 2 (thousands), 6 (ten-thousands), 1 (hundred-thousands), 3 (millions).
  • \(s_1 = 3 + 6 + 8 + 9 = 26\).
  • \(s_2 = 1 + 2 + 1 = 4\).

Since \(26 \bmod 11 = 4\) and \(4 \bmod 11 = 4\), the number \(3162819\) is a multiple of \(11\).

inputFormat

The input consists of a single line containing a positive integer \(x\) in its decimal representation. \(x\) can be a large number, so it is given as a string of digits with no leading zeros.

outputFormat

Output a single line: Yes if \(x\) is a multiple of \(11\) according to the method described; otherwise, output No.

sample

3162819
Yes