关注
import java.util.ArrayList;import java.util.Scanner;import java.util.List;import java.util.concurrent.*; public class Main { private static volatile int index = 0;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
final List<String> list = new ArrayList<String>();
while (sc.hasNext()){
list.add(sc.nextLine());
}
ExecutorService service = Executors.newFixedThreadPool(3);
Future<Integer> result = service.submit(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
for (int j = 0; j < list.size(); j++) {
for (int i = 0; i < list.get(j).length(); i++) {
if (list.get(j).charAt(i) == 'u') {
if (i + 1 < list.get(j).length() && list.get(j).charAt(i + 1) == '5') {
if (i + 2 < list.get(j).length() && list.get(j).charAt(i + 2) == '1') {
index++;
}
}
}
}
}
return index;
}
});
try {
System.out.println(result.get());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
} finally {
service.shutdown();
}
}
}这样子AC了~
查看原帖
点赞 1
相关推荐

点赞 评论 收藏
分享
牛客热帖
更多
正在热议
更多
# 我的实习收获 #
27033次浏览 462人参与
# 非技术岗简历怎么写 #
209458次浏览 2857人参与
# 实习吐槽大会 #
28429次浏览 136人参与
# 26届秋招投递记录 #
2673次浏览 87人参与
# 晒一晒你的工位 #
84924次浏览 302人参与
# 2025牛客秋招季 #
2678次浏览 89人参与
# 如果有时光机,你最想去到哪个年纪? #
46889次浏览 796人参与
# 双非能在秋招上岸吗? #
214901次浏览 1137人参与
# 我的租房踩坑经历 #
23617次浏览 254人参与
# 打工人的工作餐日常 #
40356次浏览 343人参与
# 穿越回高考你还会选现在的专业吗 #
19763次浏览 251人参与
# 软开人,说说你的烦心事 #
48002次浏览 359人参与
# 被AI治愈的瞬间 #
52191次浏览 597人参与
# 毕业旅行去哪玩儿 #
1123次浏览 32人参与
# 怎么防止在试用期被辞退 #
122236次浏览 910人参与
# 关于提前批我想问 #
201760次浏览 2143人参与
# 高学历就一定能找到好工作吗? #
47570次浏览 591人参与
# 携程求职进展汇总 #
531207次浏览 3962人参与
# 打工人锐评公司红黑榜 #
145597次浏览 912人参与
# 夸夸我的求职搭子 #
190932次浏览 1891人参与