結果

問題 No.346 チワワ数え上げ問題
ユーザー fal_rndfal_rnd
提出日時 2016-10-29 01:37:22
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 323 bytes
コンパイル時間 2,730 ms
コンパイル使用メモリ 74,316 KB
実行使用メモリ 44,652 KB
最終ジャッジ日時 2024-05-03 08:36:46
合計ジャッジ時間 8,215 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
41,020 KB
testcase_01 AC 137 ms
41,896 KB
testcase_02 AC 126 ms
41,224 KB
testcase_03 AC 128 ms
41,248 KB
testcase_04 AC 140 ms
41,608 KB
testcase_05 AC 127 ms
41,400 KB
testcase_06 AC 143 ms
40,892 KB
testcase_07 AC 142 ms
41,652 KB
testcase_08 AC 135 ms
40,848 KB
testcase_09 AC 142 ms
41,644 KB
testcase_10 WA -
testcase_11 AC 213 ms
42,748 KB
testcase_12 WA -
testcase_13 AC 225 ms
43,384 KB
testcase_14 AC 156 ms
42,240 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 219 ms
42,524 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 127 ms
41,220 KB
testcase_24 AC 124 ms
41,384 KB
testcase_25 AC 123 ms
41,076 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=-1, 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