結果

問題 No.346 チワワ数え上げ問題
ユーザー kenji_shioyakenji_shioya
提出日時 2016-05-29 09:19:33
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 476 bytes
コンパイル時間 3,356 ms
コンパイル使用メモリ 75,332 KB
実行使用メモリ 42,524 KB
最終ジャッジ日時 2024-04-16 18:14:31
合計ジャッジ時間 8,491 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
41,308 KB
testcase_01 AC 127 ms
41,508 KB
testcase_02 AC 128 ms
41,240 KB
testcase_03 AC 112 ms
40,156 KB
testcase_04 AC 128 ms
41,040 KB
testcase_05 AC 124 ms
41,180 KB
testcase_06 AC 128 ms
41,284 KB
testcase_07 AC 129 ms
41,192 KB
testcase_08 AC 131 ms
41,440 KB
testcase_09 AC 131 ms
41,520 KB
testcase_10 AC 202 ms
42,320 KB
testcase_11 AC 189 ms
41,872 KB
testcase_12 AC 200 ms
42,232 KB
testcase_13 AC 180 ms
41,796 KB
testcase_14 AC 145 ms
41,392 KB
testcase_15 AC 187 ms
42,436 KB
testcase_16 AC 189 ms
42,384 KB
testcase_17 AC 201 ms
42,248 KB
testcase_18 AC 197 ms
42,228 KB
testcase_19 AC 182 ms
42,524 KB
testcase_20 AC 196 ms
42,520 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 126 ms
41,252 KB
testcase_24 AC 128 ms
41,364 KB
testcase_25 AC 127 ms
41,140 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;
    int 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