結果

問題 No.346 チワワ数え上げ問題
ユーザー troro_kelptroro_kelp
提出日時 2018-06-22 18:06:16
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 506 bytes
コンパイル時間 1,093 ms
コンパイル使用メモリ 144,648 KB
実行使用メモリ 11,484 KB
最終ジャッジ日時 2023-09-13 08:03:14
合計ジャッジ時間 4,922 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int combination(int a, int b){
    if(a==0||b==0||a==b) return 1;
    return combination(a-1, b) + combination(a-1, b-1);
}
int main() {
    string str; cin >> str;
    int cnt_w=0;
    for(int i=0; i<str.size(); ++i)  if(str[i]=='w') cnt_w++;
    
    long long ans=0;
    for(int i=0; i<str.size(); ++i){
        if(str[i]=='c'){
            ans += combination(cnt_w, 2);
        }else if(str[i]=='w') cnt_w--;
    }
    cout << ans << endl;
    return 0;
}
0