Advertisement
a53

Veverita

a53
Feb 21st, 2020
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream fin("veverita.in");
  5. ofstream fout("veverita.out");
  6. const int MOD = 666013;
  7. unsigned long long n;
  8.  
  9. int main()
  10. {
  11. fin >> n;
  12. if(n <= 1000)
  13. {
  14. /// numere mari
  15. int R[1000];
  16. R[0] = 1;
  17. if(n % 2 == 0)
  18. R[1] = 2;
  19. else
  20. R[1] = 3;
  21. n /= 2;
  22. for(int i = 1 ; i <= n ; i ++)
  23. {
  24. int t = 0;
  25. for(int j = 1; j <= R[0] ; j ++)
  26. {
  27. int x = t + R[j] * 2;
  28. R[j] = x % 10;
  29. t = x / 10;
  30. }
  31. while(t)
  32. R[++R[0]] = t % 10, t /= 10;
  33. }
  34. for(int i = R[0] ; i > 0 ; i --)
  35. fout << R[i];
  36.  
  37. }
  38. else
  39. {
  40. int F = (n % 2 == 0)?2:3;
  41. n /= 2;
  42. int A = 2, R = 1;
  43. while(n > 0)
  44. {
  45. if(n % 2 == 1)
  46. R = 1ULL * R * A % MOD;
  47. A = 1ULL * A * A % MOD;
  48. n /= 2;
  49. }
  50. fout << 1LL * F * R % MOD;
  51. }
  52.  
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement