結果

問題 No.346 チワワ数え上げ問題
ユーザー pink_bangbi
提出日時 2016-02-28 22:22:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 547 bytes
コンパイル時間 832 ms
コンパイル使用メモリ 57,832 KB
実行使用メモリ 13,884 KB
最終ジャッジ日時 2024-09-24 12:18:04
合計ジャッジ時間 7,493 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other WA * 1 TLE * 1 -- * 21
権限があれば一括ダウンロードができます

ソースコード

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