Advertisement
a53

codred

a53
Apr 22nd, 2021 (edited)
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int p=1000000007;
  4.  
  5. unsigned long long Fact(int n)
  6. {
  7.  
  8. unsigned long long a1=1,a2=1;
  9. int z;
  10. if(n%2) z=(n+1)/2; else z=(n)/2;
  11. for(int i=1;i<=z;++i)
  12. {
  13. if(2*i<=n) a1=a1*2*i%p;
  14. a2=a2*(2*i-1)%p;
  15. }
  16. return a1*a2%p;
  17. }
  18.  
  19. int main()
  20. {
  21. //ios_base::sync_with_stdio(false);
  22. //cin.tie(0);
  23. int n;
  24. cin>>n;
  25. ++n;
  26. cout<<(n*Fact(n)%p-1)%p;
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement