結果

問題 No.346 チワワ数え上げ問題
ユーザー ぬるぬるぬるぬる
提出日時 2016-05-15 02:32:43
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 623 bytes
コンパイル時間 3,645 ms
コンパイル使用メモリ 74,196 KB
実行使用メモリ 38,988 KB
最終ジャッジ日時 2024-04-15 21:42:43
合計ジャッジ時間 5,969 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
37,148 KB
testcase_01 AC 48 ms
36,928 KB
testcase_02 AC 49 ms
36,976 KB
testcase_03 AC 49 ms
36,664 KB
testcase_04 AC 48 ms
37,148 KB
testcase_05 AC 48 ms
37,148 KB
testcase_06 AC 48 ms
36,940 KB
testcase_07 AC 50 ms
36,896 KB
testcase_08 AC 48 ms
37,196 KB
testcase_09 AC 48 ms
36,936 KB
testcase_10 WA -
testcase_11 AC 61 ms
37,604 KB
testcase_12 WA -
testcase_13 AC 57 ms
37,172 KB
testcase_14 AC 48 ms
36,696 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 67 ms
38,332 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 49 ms
36,668 KB
testcase_24 AC 48 ms
36,824 KB
testcase_25 AC 49 ms
36,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

	public static void main(String[] args) {
		int result = 0;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			int 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