科大讯飞好难。。

package main;

import java.util.*;

/* LRLR */
public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		String line = in.nextLine();

		int firstR = line.indexOf('R');
		if (firstR == -1) {
			System.out.println(line.length());
			return;
		}

		int result = firstR + 1;

		int count = 0;
		for (int i = firstR + 1; i < line.length(); i++) {
			if(line.charAt(i) == 'R') {
				count++;
			}
			if(count > 0 && line.charAt(i) == 'L') {
				count = 0;
			}
		}

		result += count;
		
		System.out.println(result);
	}

}

全部评论
第一道AC了,球赛0,选课40。。感觉都对着呢啊,什么鬼
点赞 回复 分享
发布于 2017-09-16 17:12
有球赛ac的大佬吗,求指导
点赞 回复 分享
发布于 2017-09-16 17:20
感觉难都不难,思路都挺好想的 但是AC不了太蛋疼
点赞 回复 分享
发布于 2017-09-16 17:23
球赛只过30,而且不知道错在哪
点赞 回复 分享
发布于 2017-09-16 17:33
只做了前两道题, 第一题AC 第二题, 有bug, 没通过。。。时间不够 import java.util.*; import java.util.Comparator; public class Main{          public static class Team{         public String name;//队伍名称         public int win;//胜利次数         public int lose;//失败次数         public int equ;//平分次数         public int ball;//进球个数                  public Team(String name){             this.name = name;             this.win = 0;             this.lose = 0;             this.equ = 0;             this.ball = 0;         }         public String getName() {             return name;         }         public void setName(String name) {             this.name = name;         }         public int getWin() {             return win;         }         public void setWin(int win) {             this.win = win;         }         public int getLose() {             return lose;         }         public void setLose(int lose) {             this.lose = lose;         }         public int getEqu() {             return equ;         }         public void setEqu(int equ) {             this.equ = equ;         }         public int getBall() {             return ball;         }         public void setBall(int ball) {             this.ball = ball;         }                       }          public static class TeamComparator implements Comparator<Team> {         @Override         public int compare(Team t1, Team t2){             int score2 = t2.getWin()*3 + t2.getEqu();             int score1 = t1.getWin()*3 + t1.getEqu();                          if(score2 > score1){//按照积分大小降序                 return score2 - score1;             }else if(score2 == score1){//积分相同时候                 int n2 = t2.getWin() + t2.getEqu() - t2.getLose();//t2净胜球数量                 int n1 = t1.getWin() + t1.getEqu() - t1.getLose();//t1净胜球数量                 if(n2 > n1){                     return n2 - n1;//净胜球数量降序                 }             }                          return (t2.getWin() + t2.getEqu()) - (t1.getWin() + t1.getEqu());//仍然相同的按进球数降序排列。         }              }      //2 //a //A //a-A 2:1          public static void main(String[] args){         Scanner sc = new Scanner(System.in);         Team[] team;//参赛队伍数组         HashMap<String, Team> map = new HashMap<>();                  while(sc.hasNextLine()){             int n = Integer.parseInt(sc.nextLine());//参赛队伍数量             int k = n*(n-1)/2;//循环读取比赛数据             team = new Team[n];//初始化参赛队伍数量             String line = "";             //创建队伍 并 初始化为空             for(int i=0; i<n; i++)                 map.put(sc.nextLine(), null);                          for(int i=0; i<k; i++){                 String in = sc.nextLine();//读入一行比赛数据                 String t1_name = in.split(" ")[0].split("-")[0];                 String t2_name = in.split(" ")[0].split("-")[1];                 int t1 = Integer.parseInt(in.split(" ")[1].split(":")[0]);                 int t2 = Integer.parseInt(in.split(" ")[1].split(":")[1]);                                  if(map.containsKey(t1_name) && map.get(t1_name) != null){//如果存在t1这个队伍                     Team temp1 = map.get(t1_name);                     if(t1 > t2){//t1胜一场 t2输一场                         temp1.setWin(temp1.getWin() + 1);                     }else if(t1 < t2){                         temp1.setLose(temp1.getLose() +1);//t1 lose1  t2 win1                     }else{                         temp1.setEqu(temp1.getEqu() + 1);//平分一次                     }                     //更新进球个数                     temp1.setBall(temp1.getBall() + t1);                     map.put(t1_name, temp1);                                      }else{//如果不存在t1这个队伍                     Team temp1 = new Team(t1_name);                     if(t1 > t2){//t1胜一场 t2输一场                         temp1.setWin(1);                     }else if(t1 < t2){                         temp1.setLose(1);//t1 lose1  t2 win1                     }else{                         temp1.setEqu(1);//平分一次                     }                     //进球个数                     temp1.setBall(t1);                     map.put(t1_name, temp1);                 }                                  if(map.containsKey(t2_name)  && map.get(t2_name) != null){//如果存在t2这个队伍                     Team temp2 = map.get(t2_name);                     if(t2 > t1){//t2胜一场 t1输一场                         temp2.setWin(temp2.getWin() + 1);                     }else if(t1 > t2){//t2输                         temp2.setLose(temp2.getLose() +1);//t2 lose1  t1 win1                     }else{                         temp2.setEqu(temp2.getEqu() + 1);//平分一次                     }                     //更新进球个数                     temp2.setBall(temp2.getBall() + t2);                     map.put(t2_name, temp2);                                      }else{//如果不存在t2这个队伍                     Team temp2 = new Team(t2_name);                     if(t2 > t1){//t2胜一场 t2输一场                         temp2.setWin(1);                     }else if(t1 < t2){                         temp2.setLose(1);//t1 lose1  t2 win1                     }else{                         temp2.setEqu(1);//平分一次                     }                     //进球个数                     temp2.setBall(t2);                     map.put(t2_name, temp2);                 }                                                   int index = 0;                 for(Map.Entry<String, Team> entry : map.entrySet()){//遍历出所有队伍的信息                     team[index] = entry.getValue();                     index++;                 }                                  //按照排序规则排序                 Arrays.sort(team, new TeamComparator());                                  for(int j=0; j< n/2; j++){                     Team temp = team[j];                     System.out.println(temp.name);                 }                              }         }              } }
点赞 回复 分享
发布于 2017-09-16 17:43

相关推荐

vegetable_more_exercise:1-1.5万,没错啊,最少是1人民币,在区间内
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务