Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin("input.txt");
- ofstream fout("output.txt");
- int n, m, s;
- int memo[3000000][30];
- struct numeri{
- int first;
- int second;
- };
- numeri T, v[30];
- int f(int h, int p){
- if(memo[h][p]!=0){
- return memo[h][p]%10000000007;
- }else{
- for(int x=v[p-1].first; x<=h/2; x++){
- f(x, p-1);
- memo[h][p]+=memo[x][p-1]%1000000007;
- }
- }
- }
- int main(){
- cin >> n >> m;
- int a=m;
- for(int x=n; x>=1; x--){
- T.first=pow(2, x-1);
- T.second=a;
- a/=2;
- v[x]=T;
- }
- for(int x=1; x<=v[n].second; x++){
- memo[x][1]=1;
- }
- for(int x=v[n].first; x<=v[n].second; x++){
- f(x, n);
- }
- for(int x=v[n].first; x<=v[n].second; x++){
- s+=memo[x][n]%1000000007;
- }
- cout << s%1000000007;
- }
Advertisement
Add Comment
Please, Sign In to add comment