Advertisement
a53

acadele

a53
Jan 23rd, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. long long int n,k,p,x,sol;
  4.  
  5. int main()
  6. {
  7. cin>>n;
  8. if(n==1)
  9. sol=3;
  10. else
  11. if(n==2)
  12. sol=9;
  13. else
  14. {
  15. k=n%2020;
  16. sol=(k*k+3*k+8)%2020;
  17. p=1;
  18. x=2;
  19. n=n-3;
  20. while(n>0)
  21. {
  22. if(n&1)
  23. p=(p*x)%2020,--n;
  24. x=(x*x)%2020 ;
  25. n/=2 ;
  26. }
  27. sol=(sol*p)%2020;
  28. }
  29. cout<<sol;
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement