結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
57,960 KB
testcase_01 AC 134 ms
57,848 KB
testcase_02 AC 130 ms
57,688 KB
testcase_03 AC 126 ms
57,792 KB
testcase_04 AC 126 ms
57,716 KB
testcase_05 AC 123 ms
57,976 KB
testcase_06 AC 125 ms
57,844 KB
testcase_07 AC 126 ms
57,956 KB
testcase_08 AC 124 ms
57,712 KB
testcase_09 AC 125 ms
57,840 KB
testcase_10 AC 205 ms
58,300 KB
testcase_11 AC 201 ms
58,088 KB
testcase_12 AC 208 ms
58,228 KB
testcase_13 AC 173 ms
58,116 KB
testcase_14 AC 135 ms
57,968 KB
testcase_15 AC 201 ms
58,224 KB
testcase_16 AC 203 ms
58,100 KB
testcase_17 AC 204 ms
58,120 KB
testcase_18 AC 203 ms
58,460 KB
testcase_19 AC 203 ms
56,632 KB
testcase_20 AC 205 ms
58,176 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 126 ms
57,668 KB
testcase_24 AC 127 ms
57,692 KB
testcase_25 AC 125 ms
57,832 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();
		int 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