Advertisement
icatalin

alo, merge 33%

Jan 25th, 2014
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. ifstream x("alo.in");
  8. ofstream y("alo.out");
  9.  
  10. int main()
  11. {
  12.     int v[100],n,i,E,nr,nr2,d,prima;
  13.     x>>E>>n;
  14.  
  15.     i=0;
  16.  
  17.     while (i<=n*2)
  18.     {
  19.         i++;
  20.         x>>nr>>d;
  21.         nr2=nr;
  22.         while (nr2)
  23.         {
  24.             prima=nr2%10;
  25.             nr2=nr2/10;
  26.         }
  27.         if (prima==1 && (nr%10)==9)
  28.                 E=E;
  29.         else
  30.         if (prima==2 && (nr%10)==9)
  31.                E=E;
  32.         else
  33.         if (prima==1 && (nr%10)==5)
  34.         E=E-d*2;
  35.         else
  36.         if (prima==2 && (nr%10)==5)
  37.         E=E+d;
  38.     }
  39.     y<<E;
  40.  
  41.     x.close();
  42.     y.close();
  43.  
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement