結果

問題 No.346 チワワ数え上げ問題
ユーザー kenji_shioya
提出日時 2016-05-29 09:26:10
言語 Java
(openjdk 23)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 477 bytes
コンパイル時間 3,304 ms
コンパイル使用メモリ 74,476 KB
実行使用メモリ 54,732 KB
最終ジャッジ日時 2024-10-07 17:38:01
合計ジャッジ時間 8,183 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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