結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
41,280 KB
testcase_01 AC 126 ms
41,280 KB
testcase_02 AC 128 ms
41,244 KB
testcase_03 AC 123 ms
41,176 KB
testcase_04 AC 126 ms
41,352 KB
testcase_05 AC 125 ms
40,956 KB
testcase_06 AC 113 ms
40,428 KB
testcase_07 AC 127 ms
41,360 KB
testcase_08 AC 114 ms
40,328 KB
testcase_09 AC 125 ms
41,268 KB
testcase_10 WA -
testcase_11 AC 171 ms
41,616 KB
testcase_12 WA -
testcase_13 AC 180 ms
41,708 KB
testcase_14 AC 126 ms
40,224 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 185 ms
42,608 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 124 ms
41,448 KB
testcase_24 AC 123 ms
41,276 KB
testcase_25 AC 109 ms
40,188 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