Korotkodul

J_сетка чисел

Dec 29th, 2021 (edited)
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <queue>
  5. #include <algorithm>
  6. #include <string>
  7. #include <stack>
  8. #include <set>
  9. #include <map>
  10. #define pii pair <int,int>
  11. using namespace std;
  12. using ll = long long;
  13. using ld = long double;
  14. void cv(vector <ll> &v){
  15.     for (auto x: v) cout<<x<<' ';
  16.     cout<<"\n";
  17. }
  18.  
  19. ll inf = 1e9 + 7;
  20.  
  21.  
  22. ll S(ll b1, ll q, ll n){
  23.     //return (b1 - b1 * pow(q, n)) / (1 - q);
  24.     ll r = b1 * ( pow(q, n) - 1);
  25.     r %= inf;
  26.     return r;
  27. }
  28.  
  29. int main()
  30. {
  31.     /*ios::sync_with_stdio(0);
  32.     cin.tie(0);
  33.     cout.tie(0);*/
  34.     ll n;
  35.     cin>>n;
  36.     n++;
  37.     vector <ll> dp(n+1);
  38.     dp[1] = 1;
  39.     ll b1, q=2, num;
  40.     for (ll i = 2; i <= n;++i){
  41.         b1 = pow(2, n - i);
  42.         dp[i] = dp[i-1] * ( S(b1, q, i) % inf );
  43.         dp[i] %= inf;
  44.     }
  45.     //cv(dp);
  46.     cout<<dp[n-1];
  47. }
  48.  
Add Comment
Please, Sign In to add comment