1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import java.util.Scanner; /** * UVA10929 */ public class UVA10929 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { String str = sc.next(); if (str.equals("0")) break; boolean odd = true; int sum = 0; for (int i = str.length() - 1; i >= 0; i--) { sum += odd ? str.charAt(i) - '0' : -(str.charAt(i) - '0'); odd = !odd; } System.out.printf("%s is%s a multiple of 11.\r\n", str, sum % 11 == 0 ? "" : " not"); } sc.close(); } } |