結果

問題 No.346 チワワ数え上げ問題
ユーザー ぬるぬるぬるぬる
提出日時 2016-05-15 02:37:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 625 bytes
コンパイル時間 2,967 ms
コンパイル使用メモリ 73,996 KB
実行使用メモリ 39,240 KB
最終ジャッジ日時 2024-04-15 21:42:51
合計ジャッジ時間 5,319 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
37,096 KB
testcase_01 AC 48 ms
36,824 KB
testcase_02 AC 48 ms
36,932 KB
testcase_03 AC 48 ms
36,936 KB
testcase_04 AC 48 ms
37,228 KB
testcase_05 AC 50 ms
37,092 KB
testcase_06 AC 49 ms
37,148 KB
testcase_07 AC 50 ms
36,936 KB
testcase_08 AC 49 ms
36,940 KB
testcase_09 AC 49 ms
37,076 KB
testcase_10 AC 85 ms
38,852 KB
testcase_11 AC 60 ms
37,208 KB
testcase_12 AC 65 ms
37,896 KB
testcase_13 AC 58 ms
37,396 KB
testcase_14 AC 50 ms
36,924 KB
testcase_15 AC 64 ms
38,172 KB
testcase_16 AC 67 ms
38,344 KB
testcase_17 AC 77 ms
38,800 KB
testcase_18 AC 77 ms
38,524 KB
testcase_19 AC 65 ms
38,016 KB
testcase_20 AC 69 ms
38,232 KB
testcase_21 AC 78 ms
39,240 KB
testcase_22 AC 85 ms
38,680 KB
testcase_23 AC 49 ms
37,196 KB
testcase_24 AC 49 ms
37,012 KB
testcase_25 AC 49 ms
36,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test346 {

	public static void main(String[] args) {
		long result = 0;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			long count_w = 0;
			String str = br.readLine();
			char[] ch = str.toCharArray();
			for(int i=ch.length-1;i>=0;i--){
				if(ch[i]=='w'){
					count_w++;
				}else if(ch[i]=='c'){
					if(count_w >= 2){
						result += count_w * (count_w - 1) / 2 ;
					}
				}
			}
			System.out.println(result);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
0