結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
![]() |
提出日時 | 2016-03-03 00:29:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 343 bytes |
コンパイル時間 | 609 ms |
コンパイル使用メモリ | 56,792 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 13:37:50 |
合計ジャッジ時間 | 1,684 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <iostream> #include <string> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio( false ); string s; cin >> s; ll n = 0; ll ret = 0; for( int i=s.size()-1; i>=0; i-- ){ if( s[i] == 'w' ) { n++; } else if( s[i] == 'c' ) { ret += n * (n-1) / 2; } } cout << ret << endl; }