結果
問題 |
No.346 チワワ数え上げ問題
|
ユーザー |
|
提出日時 | 2016-02-26 23:27:26 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 556 bytes |
コンパイル時間 | 647 ms |
コンパイル使用メモリ | 64,272 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-23 01:16:49 |
合計ジャッジ時間 | 3,350 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 WA * 5 RE * 13 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:24:9: warning: ‘w’ may be used uninitialized in this function [-Wmaybe-uninitialized] 24 | if (w<=1) break; | ^~
ソースコード
#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(){ char c; int i,w,j,n; int s[100000]; i=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; }