結果

問題 No.346 チワワ数え上げ問題
ユーザー a
提出日時 2016-07-09 03:49:17
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 327 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 32,128 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-13 08:04:03
合計ジャッジ時間 1,057 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>

using namespace std;

char s[111111];

int main(void) {
  int w = 0;
  scanf("%s", s);
  int l = strlen(s);
  long long res = 0;
  for (int i = l-1; i >= 0; i--) {
    if (s[i] == 'w') w += 1;
    if (s[i] == 'c') {
      res += w*(w-1)/2;
    }
  }
  printf("%lld\n", res);
  return 0;
}
0