結果

問題 No.346 チワワ数え上げ問題
ユーザー jp_ste
提出日時 2016-02-28 20:55:35
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 541 bytes
コンパイル時間 2,320 ms
コンパイル使用メモリ 74,400 KB
実行使用メモリ 55,104 KB
最終ジャッジ日時 2024-09-24 12:08:04
合計ジャッジ時間 7,412 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scan = new Scanner(System.in)) {
            String S = scan.nextLine();
            int count = 0;
            int ans = 0;
            for(int i=S.length()-1; i>=0; i--) {
                if(S.charAt(i) == 'w') {
                    count++;
                } else if(S.charAt(i) == 'c') {
                    ans += count * (count-1) / 2;
                }
            }
            System.out.println(ans);
        }
    }
}
0