Sample input
2
4 3 2 1 1
3 4 5 5
Samples Output
7
14
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 | import java.util.*; import java.lang.*; import java.math.*; public class Mock1{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); String line =System.getProperty("line.separator"); scan.useDelimiter(line); int cases = scan.nextInt(); for(int x=0;x<cases;x++){ String [] get = scan.next().split(" "); int total=0; for(int y=1;y<get.length;y++){ total = total + Integer.parseInt(get[y]); } System.out.println(total); } } } |
No comments:
Post a Comment