結果

問題 No.346 チワワ数え上げ問題
ユーザー fal_rndfal_rnd
提出日時 2016-10-29 01:37:22
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 323 bytes
コンパイル時間 2,075 ms
コンパイル使用メモリ 74,028 KB
実行使用メモリ 44,376 KB
最終ジャッジ日時 2024-11-24 07:04:57
合計ジャッジ時間 7,606 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
40,320 KB
testcase_01 AC 133 ms
41,300 KB
testcase_02 AC 125 ms
40,980 KB
testcase_03 AC 127 ms
41,300 KB
testcase_04 AC 145 ms
41,628 KB
testcase_05 AC 124 ms
41,136 KB
testcase_06 AC 143 ms
40,956 KB
testcase_07 AC 134 ms
41,012 KB
testcase_08 AC 139 ms
41,324 KB
testcase_09 AC 143 ms
41,080 KB
testcase_10 WA -
testcase_11 AC 214 ms
43,268 KB
testcase_12 WA -
testcase_13 AC 207 ms
42,732 KB
testcase_14 AC 157 ms
42,812 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 209 ms
42,280 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 113 ms
39,808 KB
testcase_24 AC 124 ms
41,120 KB
testcase_25 AC 119 ms
40,988 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