結果

問題 No.346 チワワ数え上げ問題
ユーザー pink_bangbipink_bangbi
提出日時 2016-02-28 22:39:29
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 623 bytes
コンパイル時間 528 ms
コンパイル使用メモリ 58,928 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 18:54:26
合計ジャッジ時間 6,693 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 141 ms
4,348 KB
testcase_11 AC 48 ms
4,348 KB
testcase_12 AC 83 ms
4,348 KB
testcase_13 AC 39 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 77 ms
4,348 KB
testcase_16 AC 100 ms
4,348 KB
testcase_17 AC 138 ms
4,348 KB
testcase_18 AC 136 ms
4,348 KB
testcase_19 AC 101 ms
4,348 KB
testcase_20 AC 3 ms
4,348 KB
testcase_21 TLE -
testcase_22 TLE -
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

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

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