Advertisement
a53

insule01

a53
Oct 27th, 2020 (edited)
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #include <iostream>
  2. #define M 1000000007
  3. using namespace std;
  4.  
  5. long long int pow(long long int n,long long int p)
  6. {
  7. long long int r;
  8. r=1;
  9. while(p>0)
  10. {
  11. if(p%2==1)
  12. r=(r*n)%M;
  13. n=(n*n)%M;
  14. p/=2;
  15. }
  16. return r;
  17. }
  18.  
  19. int main()
  20. {
  21. long long int n;
  22. cin>>n;
  23. cout<<(pow(2,n-1)*(n+1))%M;
  24. return 0;
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement