Ac package 入门5; import java.util.Scanner; public class P1308统计单词数 { public static void main(String []args) { Scanner in = new Scanner(System.in); int num = 0,leg = 0,flag = 0,index = 0; String s = in.nextLine().toLowerCase(); String str = in.nextLine().toLowerCase(); String arr[] = str.split(" "); for(int i = 0; i < arr.length; i++) { if(s.equals(arr[i])) num++; if(num == 1) flag = 1; if(flag == 0) index += arr[i].length()+1; // System.out.println(index); } if(num == 0) { System.out.println("-1"); }else { System.out.println(num+" "+index); } } }