結果

問題 No.346 チワワ数え上げ問題
ユーザー shinwisteriashinwisteria
提出日時 2017-04-01 10:14:38
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 665 bytes
コンパイル時間 3,280 ms
コンパイル使用メモリ 72,484 KB
実行使用メモリ 62,124 KB
最終ジャッジ日時 2023-09-22 01:55:42
合計ジャッジ時間 16,082 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
58,172 KB
testcase_01 AC 124 ms
55,700 KB
testcase_02 AC 125 ms
55,528 KB
testcase_03 AC 123 ms
56,048 KB
testcase_04 AC 125 ms
55,524 KB
testcase_05 AC 128 ms
55,748 KB
testcase_06 AC 125 ms
55,944 KB
testcase_07 AC 127 ms
55,868 KB
testcase_08 AC 126 ms
55,716 KB
testcase_09 AC 127 ms
56,052 KB
testcase_10 WA -
testcase_11 AC 523 ms
57,428 KB
testcase_12 WA -
testcase_13 AC 459 ms
57,016 KB
testcase_14 AC 154 ms
55,764 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Chiwawa {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner s = new Scanner(System.in);
		StringBuilder str = new StringBuilder(s.nextLine());
		s.close();
		int all = 0;
		while(str.indexOf("c") != -1){
			int t = str.indexOf("c");
			int count = 0;
			for(int i = t;i < str.length();i++){
				if(str.charAt(i) == 'w'){
					count++;
				}
			}
			all += Combination(count,2);
			str.deleteCharAt(t);
		}
		System.out.println(all);

	}
	static int Combination(int r,int q){
		int rCq = 1;
		for(int i = 1;i <= q;i++){
			rCq = rCq * r-- / i;
		}
		return rCq;
	}

}
0