Task: | Osajono |
Sender: | niklaskoskinen |
Submission time: | 2015-09-30 16:05:59 +0300 |
Language: | Java |
Status: | COMPILE ERROR |
Compiler report
input/Test.java:12: error: incompatible types: possible lossy conversion from long to int num[ccnum] = num[ccnum] + 1; ^ input/Test.java:12: error: incompatible types: possible lossy conversion from long to int num[ccnum] = num[ccnum] + 1; ^ 2 errors
Code
import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner inp = new Scanner(System.in); String test = inp.nextLine(); long[] num; num = new long[26]; char[] testa = test.toCharArray(); for(char t : testa){ long cnum = (long) t; long ccnum = cnum - 65; num[ccnum] = num[ccnum] + 1; } long ans = 0; for(long n : num){ ans = ans + ((n * (n + 1))/2); } System.out.println(ans); } }