Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstring>
- using namespace std;
- ifstream f("nevricos.in");
- ofstream g("nevricos.out");
- char c, p;
- long long c1, c5, s15, c2, c4, s24, secv, subsir;
- int main()
- {
- f>>p;
- if (p=='1') ++c1;
- if (p=='2') ++c2;
- while (f>>c)
- {
- if ((p=='1' && c=='5')||(p=='2' && c=='4')) ++secv;
- if (c=='5') ++c5;
- if (c=='1') { s15=s15+c1*c5; ++c1; c5=0; }
- if (c=='4') ++c4;
- if (c=='2') {s24=s24+c2*c4; ++c2; c4=0;}
- p=c;
- }
- if (c5) s15=s15+c1*c5;
- if (c4) s24=s24+c2*c4;
- subsir=s15+s24;
- g << secv << "\n";
- g << subsir;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement