結果

問題 No.346 チワワ数え上げ問題
ユーザー pink_bangbipink_bangbi
提出日時 2016-02-28 22:22:28
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 547 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 58,964 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-24 18:53:28
合計ジャッジ時間 7,245 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <string>
#include <iostream>
#include <string>
#include <algorithm>

int
fact(int n){
	return n == 0 ? 0 : fact(n-1) + n;
}

int
chiwawa(std::string const& input, int start = 0){
	auto c = input.find('c', start);
	if( c == std::string::npos || c >= input.size() ) return 0;
	
	auto ws = std::count(std::begin(input)+c, std::end(input), 'w');
	auto result = fact(ws-1) + chiwawa(input, c+1);
	return result;
}

int
main(){
	std::string str;
    std::cin >> str;
	auto result = chiwawa(str);
	std::cout << result << std::endl;
	return 0;
}
0