結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
sekiya9311
|
| 提出日時 | 2016-04-19 09:32:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 997 bytes |
| コンパイル時間 | 802 ms |
| コンパイル使用メモリ | 94,320 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-10 23:59:29 |
| 合計ジャッジ時間 | 1,729 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(int (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(int (i)=(a)-1;(i)>=(b);(i)--)
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
unsigned long long Combination(long n,long r){
long i,cnt=1,buf;
buf=n;
while(cnt<r){
n*=(buf-cnt);
cnt++;
}
cnt=1;
buf=r;
while(buf-cnt>0){
r*=(buf-cnt);
cnt++;
}
return n/r;
}
int main(){
string s;
cin>>s;
LL ans=0,m=0;
RREP(i,s.size()){
if(s[i]=='w') m++;
if(s[i]=='c') ans+=Combination(m,2);
}
cout<<ans<<endl;
}
sekiya9311