結果

問題 No.346 チワワ数え上げ問題
ユーザー nglkrianbrjfnglkrianbrjf
提出日時 2016-02-26 23:07:38
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 697 bytes
コンパイル時間 4,012 ms
コンパイル使用メモリ 74,796 KB
実行使用メモリ 54,468 KB
最終ジャッジ日時 2023-10-24 05:55:07
合計ジャッジ時間 6,611 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
53,396 KB
testcase_01 AC 53 ms
53,400 KB
testcase_02 AC 53 ms
53,400 KB
testcase_03 AC 54 ms
53,404 KB
testcase_04 AC 54 ms
53,396 KB
testcase_05 AC 54 ms
53,416 KB
testcase_06 AC 54 ms
53,392 KB
testcase_07 AC 53 ms
53,408 KB
testcase_08 AC 53 ms
53,344 KB
testcase_09 AC 54 ms
53,400 KB
testcase_10 WA -
testcase_11 AC 69 ms
53,408 KB
testcase_12 WA -
testcase_13 AC 67 ms
53,396 KB
testcase_14 AC 56 ms
52,436 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 82 ms
54,128 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 54 ms
53,412 KB
testcase_24 AC 53 ms
53,396 KB
testcase_25 AC 52 ms
53,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class QuestionA {

	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;//直前のcの位置

		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