<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ~~~ # Encoding Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 34681????Accepted Submission(s): 15377 ~~~ Problem Description Given a string containing only 'A' - 'Z', we could encode it using the following method: 1. Each sub-string containing k same characters should be encoded to "kX" where "X" is the only character in this sub-string. 2. If the length of the sub-string is 1, '1' should be ignored. Input The first line contains an integer N (1 <= N <= 100) which indicates the number of test cases. The next N lines contain N strings. Each string consists of only 'A' - 'Z' and the length is less than 10000. Output For each test case, output the encoded string in a line. Sample Input ~~~ 2 ABC ABBCCC ~~~ ? Sample Output ABC A2B3C解題思路整理:對字符串進行遍歷,如果當前的字符與前面的字符相同的話那么我加1記錄其個數,如果不相同的時候,排除只有1個的情況,只有在字符重復個數大于1的時候那么認為是有多個在一起,這是將字符串拼接組成新的串繼續下一步操作。 ~~~ import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int count = scanner.nextInt(); int i = 0, countNum = 0, j = 0, j2 = 0; String str ; String str2 = ""; char sCopy = 0; List<String> list = new ArrayList<String>(); while(i < count) { str = scanner.next(); sCopy = 0; j = 0; str2 = ""; countNum = 0; while(j < str.length()) { if(sCopy != str.charAt(j)) { if(countNum > 1) { str2 = str2 + countNum + sCopy; } else if(j != 0) str2 = str2 + sCopy; countNum = 0; sCopy = str.charAt(j); } if(sCopy == str.charAt(j)) { countNum++; } j++; if(j == str.length()) { if(countNum > 1) { str2 = str2 + countNum + sCopy; } else if(j != 0) str2 = str2 + sCopy; list.add(str2); } } i++; } for(i = 0; i < count; i++) { System.out.println(list.get(i)); } } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看