Advertisement
add1ctus

COW

Feb 23rd, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     ifstream in("cow.in");
  8.     ofstream out("cow.out");
  9.     int n;
  10.     cin>>n;
  11.     char input;
  12.     long long c=0;
  13.     long long co=0;
  14.     long long result=0;
  15.  
  16.     cin>>input;
  17.  
  18.     for(int i=0;i<n;i++)
  19.     {
  20.         cin>>input;
  21.         if(input=='C')
  22.             c++;
  23.         else if(input=='O')
  24.             co+=c;
  25.         else
  26.             result+=co;
  27.     }
  28.     cout<<result;
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement