結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
pink_bangbi
|
| 提出日時 | 2016-02-28 22:39:29 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 623 bytes |
| コンパイル時間 | 413 ms |
| コンパイル使用メモリ | 58,072 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 12:19:49 |
| 合計ジャッジ時間 | 6,658 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 TLE * 2 |
ソースコード
#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;
}
pink_bangbi