Guest User

Untitled

a guest
Feb 5th, 2018
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. ifstream fin("input.txt");
  6. ofstream fout("output.txt");
  7.  
  8. int n, m, s;
  9. int memo[3000000][30];
  10.  
  11. struct numeri{
  12. int first;
  13. int second;
  14. };
  15.  
  16. numeri T, v[30];
  17.  
  18. int f(int h, int p){
  19. if(memo[h][p]!=0){
  20. return memo[h][p]%10000000007;
  21. }else{
  22. for(int x=v[p-1].first; x<=h/2; x++){
  23. f(x, p-1);
  24. memo[h][p]+=memo[x][p-1]%1000000007;
  25. }
  26. }
  27. }
  28.  
  29. int main(){
  30. cin >> n >> m;
  31. int a=m;
  32. for(int x=n; x>=1; x--){
  33. T.first=pow(2, x-1);
  34. T.second=a;
  35. a/=2;
  36. v[x]=T;
  37. }
  38. for(int x=1; x<=v[n].second; x++){
  39. memo[x][1]=1;
  40. }
  41. for(int x=v[n].first; x<=v[n].second; x++){
  42. f(x, n);
  43. }
  44. for(int x=v[n].first; x<=v[n].second; x++){
  45. s+=memo[x][n]%1000000007;
  46. }
  47. cout << s%1000000007;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment