vlatkovski

Trajko

Aug 18th, 2016
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main() {
  5.     std::string niza;
  6.     std::cin >> niza;
  7.  
  8.     long long int pari = 1;
  9.  
  10.     std::string pd = "duplo", pt = "troduplo", pm = "minus";
  11.     std::string td = "", tt = "", tm = "";
  12.  
  13.     for (unsigned int i = 0; i < niza.length(); i++) {
  14.         char x = tolower(niza[i]);
  15.  
  16.         if ((tt + x) == pt.substr(0, tt.length() + 1)) {
  17.             tt += x;
  18.  
  19.             if (pt == tt) {
  20.                 pari *= 3;
  21.                 tt = "";
  22.             }
  23.  
  24.         } else {
  25.             tt = "";
  26.  
  27.             if ((td + x) == pd.substr(0, td.length() + 1)) {
  28.                 td += x;
  29.  
  30.                 if (pd == td) {
  31.                     pari *= 2;
  32.                     td = "";
  33.                 }
  34.  
  35.             } else {
  36.                 td = "";
  37.  
  38.                 if ((tm + x) == pm.substr(0, tm.length() + 1)) {
  39.                     tm += x;
  40.  
  41.                     if (pm == tm) {
  42.                         pari--;
  43.                         tm = "";
  44.                     }
  45.  
  46.                 } else {
  47.                     tm = "";
  48.                 }
  49.             }
  50.         }
  51.  
  52.  
  53.     }
  54.  
  55.     std::cout << pari << std::endl;
  56.  
  57.     return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment