Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. /// Moca Andrei - 100p
  2. #include <fstream>
  3. using namespace std;
  4. const int mod = 301104;
  5. long long x = 3, y = 5, z = 8, ax, ay;
  6. int n;
  7. int main()
  8. {
  9. ifstream fin("bilean.in");
  10. fin >> n;
  11. fin.close();
  12.  
  13. for (int i{4}; i <= n; ++i)
  14. {
  15. ax = x;
  16. ay = y;
  17. x = y;
  18. y = z;
  19. z = ax + ay;
  20. if (x > mod)
  21. x -= mod, y -= mod, z -= mod;
  22. else
  23. if (y > mod)
  24. y -= mod, z -= mod;
  25. else
  26. if (z > mod)
  27. z -= mod;
  28. }
  29.  
  30. ofstream fout("bilean.out");
  31. if (n == 2)
  32. fout << 3;
  33. else
  34. if (n == 3)
  35. fout << 5;
  36. else
  37. fout << z;
  38. fout.close();
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement