結果

問題 No.346 チワワ数え上げ問題
ユーザー skhtskht
提出日時 2016-02-27 21:27:56
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 286 bytes
コンパイル時間 695 ms
コンパイル使用メモリ 55,564 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 11:49:54
合計ジャッジ時間 1,738 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

int main() {
    std::string s;
    long long int c = 0, w = 0;
    std::cin >> s;
    for (int i = s.length(); i >= 0; i--)
        if (s[i] == 'c') c += w * (w - 1) / 2; // wC2
        else if (s[i] == 'w') w += 1;
    std::cout << c << std::endl;
    return 0;
}
0