結果
問題 |
No.346 チワワ数え上げ問題
|
ユーザー |
![]() |
提出日時 | 2016-02-28 22:37:14 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 581 bytes |
コンパイル時間 | 519 ms |
コンパイル使用メモリ | 57,932 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-24 12:18:19 |
合計ジャッジ時間 | 6,862 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 7 TLE * 2 |
ソースコード
#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 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; }