結果

問題 No.346 チワワ数え上げ問題
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-22 15:21:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 237 ms / 2,000 ms
コード長 343 bytes
コンパイル時間 2,381 ms
コンパイル使用メモリ 74,732 KB
実行使用メモリ 58,384 KB
最終ジャッジ日時 2024-04-08 21:15:03
合計ジャッジ時間 8,218 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 143 ms
57,676 KB
testcase_01 AC 144 ms
57,692 KB
testcase_02 AC 141 ms
57,700 KB
testcase_03 AC 142 ms
57,716 KB
testcase_04 AC 145 ms
57,692 KB
testcase_05 AC 137 ms
57,692 KB
testcase_06 AC 145 ms
56,252 KB
testcase_07 AC 141 ms
56,012 KB
testcase_08 AC 144 ms
57,684 KB
testcase_09 AC 144 ms
57,680 KB
testcase_10 AC 223 ms
58,308 KB
testcase_11 AC 219 ms
58,292 KB
testcase_12 AC 227 ms
58,332 KB
testcase_13 AC 224 ms
56,256 KB
testcase_14 AC 162 ms
57,700 KB
testcase_15 AC 224 ms
58,296 KB
testcase_16 AC 237 ms
58,236 KB
testcase_17 AC 229 ms
58,336 KB
testcase_18 AC 235 ms
58,384 KB
testcase_19 AC 225 ms
58,208 KB
testcase_20 AC 228 ms
58,364 KB
testcase_21 AC 227 ms
58,224 KB
testcase_22 AC 230 ms
58,296 KB
testcase_23 AC 141 ms
57,680 KB
testcase_24 AC 144 ms
57,700 KB
testcase_25 AC 147 ms
57,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String s = sc.next();
		long w = 0;
		long num = 0;
		for (int i=s.length()-1; i>=0; i--) {
			if (s.charAt(i)=='w') {w++;}
			if (s.charAt(i)=='c') {
				num += w*(w-1)/2;
			}
		}
		System.out.println(num);
	}
}
0