結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
ykringum
|
| 提出日時 | 2019-05-01 02:39:08 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 379 bytes |
| コンパイル時間 | 374 ms |
| コンパイル使用メモリ | 29,824 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-31 12:05:42 |
| 合計ジャッジ時間 | 1,646 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <stdio.h>
#include <string.h>
int main(void) {
int w = 0;
char s[100001];
scanf("%s", &s);
int l = strlen(s);
long long res = 0;
for( int i = l - 1; i >= 0; i--) {
if( s[i] == 'w' ) {
w++;
}
else if( s[i] == 'c' ) {
res += w * (w-1ll) /2 ;
}
}
printf("%lld\n", res);
return 0;
}
ykringum