Skip to main content
Back to problems
Codeforces
Easy
Math
Number Theory
Strings
Nineteen

Given a number, determine whether it is divisible by 19 using the digit-sum style rule associated with the problem.

Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.
Problem Statement

Problem

You are given an integer as a decimal string. Determine whether it satisfies the condition for being a multiple of 19.

A common way to solve this kind of task is to repeatedly transform the number using the rule from the problem statement until the result becomes small enough to check directly.

Return whether the number is divisible by 19.

Notes

  • The input may be very large, so it is safer to treat it as a string rather than converting it directly to a fixed-width integer.
  • The intended solution relies on arithmetic properties of 19 rather than brute force division by repeated subtraction.

Input Format

  • A single decimal integer represented as a string.

Input

The input contains one number nn.

Output Format

Print YES if the number is divisible by 19, otherwise print NO.

Constraints

  • 1n1 \le |n|.
  • nn consists only of decimal digits.
  • The number may be too large for built-in integer types.
Examples
Sample cases returned by the problem API.

Example 1

Input

19

Output

YES

Explanation

19 is divisible by 19.

Example 2

Input

20

Output

NO

Explanation

20 is not divisible by 19.

Show 1 more example

Example 3

Input

190

Output

YES

Explanation

190 = 19 × 10, so it is divisible by 19.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.