1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import java.util.Scanner; /** * UVA10093 */ public class UVA10093 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNextLine()) { String str = sc.nextLine(); char[] c = str.toCharArray(); int sum = 0, max = 1, temp = 0; for (int i = 0; i < c.length; i++) { if (c[i] >= 48 && c[i] <= 57) temp = c[i] - 48; else if (c[i] >= 65 && c[i] <= 90) temp = c[i] - 65 + 10; else if (c[i] >= 97 && c[i] <= 122) temp = c[i] - 97 + 10 + 26; sum += temp; if (temp > max) max = temp; } for (int i = max; i <= 62; i++) { if (sum % i == 0) { System.out.println(i + 1); break; } else if (i == 62) { System.out.println("such number is impossible!"); } } } sc.close(); } } |