結果

問題 No.346 チワワ数え上げ問題
ユーザー kenji_shioyakenji_shioya
提出日時 2016-05-29 09:26:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 210 ms / 2,000 ms
コード長 477 bytes
コンパイル時間 3,370 ms
コンパイル使用メモリ 74,720 KB
実行使用メモリ 42,444 KB
最終ジャッジ日時 2024-04-16 18:14:45
合計ジャッジ時間 8,664 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
40,980 KB
testcase_01 AC 133 ms
41,152 KB
testcase_02 AC 128 ms
41,184 KB
testcase_03 AC 129 ms
41,268 KB
testcase_04 AC 132 ms
41,168 KB
testcase_05 AC 117 ms
40,088 KB
testcase_06 AC 130 ms
40,876 KB
testcase_07 AC 133 ms
40,952 KB
testcase_08 AC 136 ms
41,484 KB
testcase_09 AC 132 ms
40,964 KB
testcase_10 AC 202 ms
42,096 KB
testcase_11 AC 182 ms
41,800 KB
testcase_12 AC 198 ms
42,188 KB
testcase_13 AC 187 ms
41,844 KB
testcase_14 AC 152 ms
41,128 KB
testcase_15 AC 198 ms
42,192 KB
testcase_16 AC 200 ms
42,108 KB
testcase_17 AC 197 ms
42,076 KB
testcase_18 AC 210 ms
42,444 KB
testcase_19 AC 198 ms
42,048 KB
testcase_20 AC 209 ms
41,976 KB
testcase_21 AC 204 ms
41,888 KB
testcase_22 AC 203 ms
42,324 KB
testcase_23 AC 130 ms
40,916 KB
testcase_24 AC 130 ms
41,128 KB
testcase_25 AC 128 ms
41,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise30{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    String str = sc.next();
    char[] charArray = str.toCharArray();

    long count = 0;
    long w = 0;

    for (long a = charArray.length - 1; a >= 0; a--){
      if (charArray[(int) a] == 'w'){
        w++;
      }

      if (charArray[(int) a] == 'c'){
        count += w * (w - 1) / 2;
      }
    }

    System.out.println(count);
  }
}
0