結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
|
提出日時 | 2016-02-26 23:44:15 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 615 bytes |
コンパイル時間 | 625 ms |
コンパイル使用メモリ | 64,688 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-23 02:49:47 |
合計ジャッジ時間 | 1,632 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <iostream> #include <cstdio> #include <cmath> #include <vector> #include <algorithm> using namespace std; long long combi(long long n, long long r){ long long i; long long p=1; for (i=1;i<=r;i++) p=p*(n-i+1)/i; return p; } int main(){ char c; long long i,j; long long n,w; long long s[100050]; i=0;w=0; while(cin>>c){ s[i++]=(long long)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; }