結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,128 KB
testcase_01 AC 133 ms
41,312 KB
testcase_02 AC 130 ms
41,224 KB
testcase_03 AC 130 ms
41,308 KB
testcase_04 AC 131 ms
41,048 KB
testcase_05 AC 126 ms
41,136 KB
testcase_06 AC 130 ms
41,252 KB
testcase_07 AC 130 ms
41,392 KB
testcase_08 AC 135 ms
41,428 KB
testcase_09 AC 133 ms
41,520 KB
testcase_10 WA -
testcase_11 AC 187 ms
41,868 KB
testcase_12 WA -
testcase_13 AC 183 ms
41,944 KB
testcase_14 AC 142 ms
41,464 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 202 ms
42,160 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 128 ms
41,108 KB
testcase_24 AC 128 ms
41,384 KB
testcase_25 AC 130 ms
41,204 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();

    int count = 0;
    int w = 0;

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

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

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