結果

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

テストケース

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

ソースコード

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 ll MOD = 1e9+7;
const ll 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(ll 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 (ll a,ll b) {
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]);
}
int main()
{
  make();
  string s;
  cin >> s;
  ll 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