結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
![]() |
提出日時 | 2016-03-04 23:26:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 344 bytes |
コンパイル時間 | 469 ms |
コンパイル使用メモリ | 56,744 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 14:12:21 |
合計ジャッジ時間 | 1,196 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <iostream> #include <sstream> #include <cstdint> using namespace std; int main(int argc, char *argv[]) { string s; cin >> s; int64_t ans = 0, cnt = 0; for (int i = s.length() - 1; i >= 0; --i) { if (s[i] == 'w') { ++cnt; } else if (s[i] == 'c') { ans += (cnt * (cnt - 1)) / 2; } } cout << ans << endl; return 0; }