結果

問題 No.346 チワワ数え上げ問題
ユーザー fal_rndfal_rnd
提出日時 2016-10-29 12:33:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 249 ms / 2,000 ms
コード長 323 bytes
コンパイル時間 2,164 ms
コンパイル使用メモリ 73,932 KB
実行使用メモリ 44,288 KB
最終ジャッジ日時 2024-05-03 15:43:11
合計ジャッジ時間 7,865 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
41,064 KB
testcase_01 AC 128 ms
41,212 KB
testcase_02 AC 113 ms
40,604 KB
testcase_03 AC 129 ms
41,476 KB
testcase_04 AC 138 ms
41,044 KB
testcase_05 AC 119 ms
40,972 KB
testcase_06 AC 140 ms
41,372 KB
testcase_07 AC 138 ms
41,288 KB
testcase_08 AC 133 ms
40,560 KB
testcase_09 AC 145 ms
40,932 KB
testcase_10 AC 249 ms
44,288 KB
testcase_11 AC 218 ms
42,776 KB
testcase_12 AC 242 ms
44,136 KB
testcase_13 AC 217 ms
43,180 KB
testcase_14 AC 155 ms
42,812 KB
testcase_15 AC 225 ms
43,820 KB
testcase_16 AC 242 ms
44,024 KB
testcase_17 AC 246 ms
44,096 KB
testcase_18 AC 247 ms
43,544 KB
testcase_19 AC 236 ms
43,424 KB
testcase_20 AC 211 ms
42,168 KB
testcase_21 AC 216 ms
42,252 KB
testcase_22 AC 210 ms
42,060 KB
testcase_23 AC 123 ms
41,132 KB
testcase_24 AC 127 ms
41,124 KB
testcase_25 AC 111 ms
39,872 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]", "");
		long 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