Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream x("alo.in");
- ofstream y("alo.out");
- int main()
- {
- int v[100],n,i,E,nr,nr2,d,prima;
- x>>E>>n;
- i=0;
- while (i<=n*2)
- {
- i++;
- x>>nr>>d;
- nr2=nr;
- while (nr2)
- {
- prima=nr2%10;
- nr2=nr2/10;
- }
- if (prima==1 && (nr%10)==9)
- E=E;
- else
- if (prima==2 && (nr%10)==9)
- E=E;
- else
- if (prima==1 && (nr%10)==5)
- E=E-d*2;
- else
- if (prima==2 && (nr%10)==5)
- E=E+d;
- }
- y<<E;
- x.close();
- y.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement