結果

問題 No.346 チワワ数え上げ問題
ユーザー dgd1724dgd1724
提出日時 2016-11-03 06:58:39
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 838 bytes
コンパイル時間 1,425 ms
コンパイル使用メモリ 158,996 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-05-03 21:24:16
合計ジャッジ時間 5,799 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
13,756 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
6,940 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 #

#include <bits/stdc++.h>

//const static double	de_PI	= 3.14159265358979323846;
//const static int	de_MOD	= 1000000007;
//const static int	de_MAX	= 999999999;
//const static int	de_MIN = -999999999;

inline double nCr(const int n, int r) {

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == r) { return 1; }

	if (r > n / 2) { r = n / 2; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return(result);
}
int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	std::string S;
	std::cin >> S;

	double ans = 0;
	int st = 0, n = 0;

	while (S.find('c', st) != std::string::npos) {
		st = S.find('c', st) + 1;
		n = std::count(S.begin() + st, S.end(), 'w');
		if (n >= 2) { ans += nCr(n, 2); }
	}

	std::cout << ans << std::endl;
}

0