Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #define pii pair <int,int>
- using namespace std;
- using ll = long long;
- using ld = long double;
- void cv(vector <ll> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- ll inf = 1e9 + 7;
- vector <ll> lvl; //стпеень 2-ки
- ll S(ll b1, ll q, ll n){
- //return (b1 - b1 * pow(q, n)) / (1 - q);
- //ll bin = (pow(q, n) - 1);
- ll bin = lvl[n] - 1;//уже с остатком
- bin %= inf;
- ll r = (b1 % inf) * bin;
- r %= inf;
- return r;
- }
- int main()
- {
- /*ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);*/
- ll n;
- cin>>n;
- n++;
- lvl.resize(n+1);
- lvl[0] = 1;
- for (ll i = 1; i <= n; ++i){
- lvl[i] = lvl[i-1] * 2 % inf;
- }
- //cv(lvl);
- vector <ll> dp(n+1);
- dp[1] = 1;
- ll b1, q=2, num;
- for (ll i = 2; i <= n;++i){
- //b1 = pow(2, n - i);
- b1 = lvl[n-i];
- dp[i] = dp[i-1] * ( S(b1, q, i) % inf );
- dp[i] %= inf;
- }
- //cv(dp);
- cout<<dp[n-1]; //подкорректировать -- сделать так, чтобы
- }
Add Comment
Please, Sign In to add comment