結果

問題 No.346 チワワ数え上げ問題
ユーザー nenuonnenuon
提出日時 2017-07-28 00:25:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 937 bytes
コンパイル時間 797 ms
コンパイル使用メモリ 90,548 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-18 09:01:29
合計ジャッジ時間 2,078 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,016 KB
testcase_01 AC 4 ms
5,888 KB
testcase_02 AC 4 ms
5,888 KB
testcase_03 AC 4 ms
5,888 KB
testcase_04 AC 4 ms
5,888 KB
testcase_05 AC 4 ms
5,760 KB
testcase_06 AC 4 ms
5,888 KB
testcase_07 AC 4 ms
5,888 KB
testcase_08 AC 5 ms
5,888 KB
testcase_09 AC 4 ms
6,016 KB
testcase_10 AC 6 ms
6,272 KB
testcase_11 AC 6 ms
6,016 KB
testcase_12 AC 6 ms
6,272 KB
testcase_13 AC 6 ms
6,144 KB
testcase_14 AC 5 ms
6,016 KB
testcase_15 AC 5 ms
6,144 KB
testcase_16 AC 5 ms
6,016 KB
testcase_17 AC 6 ms
6,272 KB
testcase_18 AC 7 ms
6,016 KB
testcase_19 AC 7 ms
6,144 KB
testcase_20 AC 7 ms
6,144 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 4 ms
5,888 KB
testcase_24 AC 5 ms
5,760 KB
testcase_25 AC 4 ms
6,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
const int MOD = 1e9+7;
const int SIZE = 100010;
ll inv[SIZE],fac[SIZE],finv[SIZE];
void make(){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<SIZE;i++){
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
ll C (int a,int b) {
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
int main()
{
  make();
  string s;
  cin >> s;
  int cnt = 0;
  ll ans = 0;
  for(int i = s.length()-1; i >= 0; i--) {
    if(s[i]=='w') cnt++;
    if(s[i]=='c' && cnt >= 2) ans += C(cnt,2);
  }
  cout << ans << endl;
  return 0;
}
0