結果

問題 No.346 チワワ数え上げ問題
ユーザー nglkrianbrjfnglkrianbrjf
提出日時 2016-02-27 00:34:52
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 652 bytes
コンパイル時間 3,301 ms
コンパイル使用メモリ 74,912 KB
実行使用メモリ 54,472 KB
最終ジャッジ日時 2023-10-24 18:03:13
合計ジャッジ時間 5,953 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
53,548 KB
testcase_01 AC 54 ms
53,540 KB
testcase_02 AC 55 ms
53,508 KB
testcase_03 AC 54 ms
53,544 KB
testcase_04 AC 54 ms
53,544 KB
testcase_05 AC 54 ms
53,540 KB
testcase_06 AC 55 ms
53,536 KB
testcase_07 AC 54 ms
53,540 KB
testcase_08 AC 55 ms
53,548 KB
testcase_09 AC 54 ms
53,544 KB
testcase_10 WA -
testcase_11 AC 69 ms
53,548 KB
testcase_12 WA -
testcase_13 AC 65 ms
53,612 KB
testcase_14 AC 54 ms
53,544 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 77 ms
54,396 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 54 ms
53,536 KB
testcase_24 AC 53 ms
53,544 KB
testcase_25 AC 52 ms
52,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class QuestionB {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line;

		try{
			line = in.readLine();
		}catch(IOException e){
			System.out.println("0");
			return;
		}

		int result = 0;
		int wcount = 0;

		for(int i = line.length() - 1; i >= 0; i--){
			if(line.charAt(i) == 'c')
				result += wcount * (wcount - 1)/2;
			if(line.charAt(i) == 'w'){
				wcount++;
			}
		}

		System.out.println(result);
	}

}
0