結果

問題 No.346 チワワ数え上げ問題
ユーザー maimai
提出日時 2016-02-26 23:13:51
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 552 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 64,040 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 06:08:22
合計ジャッジ時間 3,210 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 WA -
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 2 ms
4,348 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:9: warning: ‘w’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   23 |         if (w<=1) break;
      |         ^~

ソースコード

diff #

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

int fact(int n){int i,j;for(i=1,j=1;i<n;j*=i)i++;return j;}
int combi(int x,int k){return fact(x)/(fact(k)*fact(x-k));}

int main(){
    int c,i,w,j,n;
    int s[100005];
    
    i=0;
    while((c=getchar())!=-1){
        s[i++]=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