結果

問題 No.346 チワワ数え上げ問題
ユーザー mai
提出日時 2016-02-26 23:40:48
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 561 bytes
コンパイル時間 517 ms
コンパイル使用メモリ 63,768 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-23 02:41:32
合計ジャッジ時間 1,440 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int combi(int n, int r){
    int i;
    int p=1;

    for (i=1;i<=r;i++)
        p=p*(n-i+1)/i;
    return p;
}

int main(){
    char c;
    int i,j;
    int n,w;
    int s[100050];
    
    i=0;w=0;
    while(cin>>c){
        s[i++]=(int)c;
        if (c=='w') w+=1;
    }
    n=0;
    for (j=0;j<i;j++){
        if (w<=1) break;
        if (s[j]=='c') n+=combi(w,2);
        if (s[j]=='w') w-=1;
    }
    
    cout<<n<<endl;
    return 0;
}
0