結果

問題 No.346 チワワ数え上げ問題
ユーザー nglkrianbrjfnglkrianbrjf
提出日時 2016-02-27 01:11:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 650 bytes
コンパイル時間 3,255 ms
コンパイル使用メモリ 74,864 KB
実行使用メモリ 54,344 KB
最終ジャッジ日時 2023-10-24 18:08:16
合計ジャッジ時間 5,863 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
53,548 KB
testcase_01 AC 49 ms
53,552 KB
testcase_02 AC 48 ms
53,552 KB
testcase_03 AC 48 ms
53,564 KB
testcase_04 AC 49 ms
52,504 KB
testcase_05 AC 48 ms
53,560 KB
testcase_06 AC 48 ms
51,568 KB
testcase_07 AC 49 ms
52,540 KB
testcase_08 AC 48 ms
53,552 KB
testcase_09 AC 48 ms
52,536 KB
testcase_10 AC 73 ms
54,272 KB
testcase_11 AC 61 ms
53,552 KB
testcase_12 AC 70 ms
54,280 KB
testcase_13 AC 60 ms
54,040 KB
testcase_14 AC 49 ms
53,552 KB
testcase_15 AC 65 ms
54,028 KB
testcase_16 AC 70 ms
54,116 KB
testcase_17 AC 74 ms
54,276 KB
testcase_18 AC 73 ms
54,324 KB
testcase_19 AC 70 ms
54,344 KB
testcase_20 AC 76 ms
54,328 KB
testcase_21 AC 74 ms
54,184 KB
testcase_22 AC 72 ms
54,296 KB
testcase_23 AC 48 ms
52,524 KB
testcase_24 AC 48 ms
53,560 KB
testcase_25 AC 48 ms
53,556 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;
		}

		long result = 0;
		long wcount = 0;

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

		System.out.println(result);
	}

}
0