結果

問題 No.346 チワワ数え上げ問題
ユーザー fal_rndfal_rnd
提出日時 2016-10-29 12:29:18
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 322 bytes
コンパイル時間 2,027 ms
コンパイル使用メモリ 74,456 KB
実行使用メモリ 58,352 KB
最終ジャッジ日時 2024-05-03 15:43:03
合計ジャッジ時間 7,217 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
54,300 KB
testcase_01 AC 128 ms
54,112 KB
testcase_02 AC 108 ms
54,124 KB
testcase_03 AC 110 ms
53,976 KB
testcase_04 AC 128 ms
54,088 KB
testcase_05 AC 118 ms
54,064 KB
testcase_06 AC 128 ms
53,968 KB
testcase_07 AC 120 ms
54,180 KB
testcase_08 AC 131 ms
53,744 KB
testcase_09 AC 118 ms
54,124 KB
testcase_10 WA -
testcase_11 AC 204 ms
56,252 KB
testcase_12 WA -
testcase_13 AC 197 ms
56,204 KB
testcase_14 AC 127 ms
55,608 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 203 ms
54,888 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 98 ms
52,752 KB
testcase_24 AC 97 ms
52,764 KB
testcase_25 AC 116 ms
54,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
class A{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		String in = s.next().replaceAll("[^cw]", "");
		int w=0, r=0;
		for(int i=in.length()-1; i>=0; --i) {
			if(in.charAt(i)=='w') {
				w++;
			}else {
				r+=w*(w-1)/2;
			}
		}
		System.out.println(r);
	}
}
0