以上是朋友圈中一奇葩貼:“2月14情人節了,我決定造福大家。第2個贊和第14個讚的,我介紹你倆認識…………咱三喫飯…你倆請…”。現給出此貼下點讚的朋友名單,請你找出那兩位要請客的倒黴蛋。
輸入格式:
輸入按照點讚的先後順序給出不知道多少個點讚的人名,每個人名佔一行,爲不超過10個英文字母的非空單詞,以回車結束。一個英文句點.
標誌輸入的結束,這個符號不算在點贊名單裏。
輸出格式:
根據點贊情況在一行中輸出結論:若存在第2個人A和第14個人B,則輸出“A and B are inviting you to dinner...”;若只有A沒有B,則輸出“A is the only one for you...”;若連A都沒有,則輸出“Momo... No one is for you ...”。
輸入樣例1:
GaoXZh
Magi
Einst
Quark
LaoLao
FatMouse
ZhaShen
fantacy
latesum
SenSen
QuanQuan
whatever
whenever
Potaty
hahaha
.
輸出樣例1:
Magi and Potaty are inviting you to dinner...
輸入樣例2:
LaoLao
FatMouse
whoever
.
輸出樣例2:
FatMouse is the only one for you...
輸入樣例3:
LaoLao
.
輸出樣例3:
Momo... No one is for you ...
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
//** Class for buffered reading int and double values *//*
class Reader {
static BufferedReader reader;
static StringTokenizer tokenizer;
// ** call this method to initialize reader for InputStream *//*
static void init(InputStream input) {
reader = new BufferedReader(new InputStreamReader(input));
tokenizer = new StringTokenizer("");
}
// ** get next word *//*
static String next() throws IOException {
while (!tokenizer.hasMoreTokens()) {
// TODO add check for eof if necessary
tokenizer = new StringTokenizer(reader.readLine());
}
return tokenizer.nextToken();
}
static boolean hasNext()throws IOException {
return tokenizer.hasMoreTokens();
}
static String nextLine() throws IOException{
return reader.readLine();
}
static char nextChar() throws IOException{
return next().charAt(0);
}
static int nextInt() throws IOException {
return Integer.parseInt(next());
}
static long nextLong() throws IOException {
return Long.parseLong(next());
}
static float nextFloat() throws IOException {
return Float.parseFloat(next());
}
}
public class Main {
public static void main(String[] args) throws IOException {
Reader.init(System.in);
ArrayList<String>names = new ArrayList<String>();
while (true) {
String temp = Reader.nextLine();
if (temp.equals(".")) {
break;
} else {
names.add(temp);
}
}
if (names.size()<2) {
System.out.println("Momo... No one is for you ...");
} else if(names.size()<14){
System.out.println(names.get(1)+" is the only one for you...");
} else {
System.out.println(names.get(1)+" and "+names.get(13)+" are inviting you to dinner...");
}
}
}