結果

問題 No.346 チワワ数え上げ問題
ユーザー ぬるぬる
提出日時 2016-05-15 02:32:43
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 623 bytes
コンパイル時間 4,591 ms
コンパイル使用メモリ 74,032 KB
実行使用メモリ 38,920 KB
最終ジャッジ日時 2024-10-06 03:07:13
合計ジャッジ時間 5,245 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 9
権限があれば一括ダウンロードができます

ソースコード

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