結果

問題 No.346 チワワ数え上げ問題
ユーザー くれちーくれちー
提出日時 2017-02-04 20:03:10
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 303 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 20,480 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 06:18:16
合計ジャッジ時間 1,162 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%s", s);
      |         ^~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#define rrep(i, n) for (i = n; i >= 0; i--)

int main() {
	static char s[100000];
	scanf("%s", s);

	int i;
	long long w = 0, ans = 0;
	rrep(i, strlen(s)) {
		if (s[i] == 'w') w++;
		if (s[i] == 'c') ans += (w - 1) * w / 2;
	}

	printf("%lld\n", ans);
	return 0;
}
0