Advertisement
stefsen

nevricos

Dec 18th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4. using namespace std;
  5. ifstream f("nevricos.in");
  6. ofstream g("nevricos.out");
  7. char c, p;
  8. long long c1, c5, s15, c2, c4, s24, secv, subsir;
  9. int main()
  10. {
  11. f>>p;
  12. if (p=='1') ++c1;
  13. if (p=='2') ++c2;
  14. while (f>>c)
  15. {
  16. if ((p=='1' && c=='5')||(p=='2' && c=='4')) ++secv;
  17. if (c=='5') ++c5;
  18. if (c=='1') { s15=s15+c1*c5; ++c1; c5=0; }
  19. if (c=='4') ++c4;
  20. if (c=='2') {s24=s24+c2*c4; ++c2; c4=0;}
  21. p=c;
  22. }
  23. if (c5) s15=s15+c1*c5;
  24. if (c4) s24=s24+c2*c4;
  25. subsir=s15+s24;
  26. g << secv << "\n";
  27. g << subsir;
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement