結果

問題 No.346 チワワ数え上げ問題
ユーザー shinwisteriashinwisteria
提出日時 2017-04-01 10:19:10
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 714 bytes
コンパイル時間 3,536 ms
コンパイル使用メモリ 72,992 KB
実行使用メモリ 57,524 KB
最終ジャッジ日時 2023-09-22 01:56:00
合計ジャッジ時間 15,868 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,044 KB
testcase_01 AC 118 ms
55,928 KB
testcase_02 AC 118 ms
55,636 KB
testcase_03 AC 116 ms
54,752 KB
testcase_04 AC 120 ms
55,520 KB
testcase_05 AC 115 ms
56,108 KB
testcase_06 AC 121 ms
55,760 KB
testcase_07 AC 121 ms
55,536 KB
testcase_08 AC 121 ms
55,492 KB
testcase_09 AC 122 ms
55,688 KB
testcase_10 AC 1,019 ms
56,828 KB
testcase_11 AC 517 ms
57,092 KB
testcase_12 AC 723 ms
57,524 KB
testcase_13 AC 450 ms
56,868 KB
testcase_14 AC 150 ms
55,708 KB
testcase_15 AC 665 ms
57,456 KB
testcase_16 AC 785 ms
57,408 KB
testcase_17 AC 1,000 ms
57,248 KB
testcase_18 AC 992 ms
57,112 KB
testcase_19 AC 825 ms
57,428 KB
testcase_20 AC 199 ms
57,448 KB
testcase_21 TLE -
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();
		long all = 0;
		while(str.indexOf("c") != -1){
			int t = str.indexOf("c");
			int count = 0;
			if(str.lastIndexOf("w") < t){
				break;
			}
			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