fork download
  1. #include<bits/stdc++.h>
  2. #include<ext/pb_ds/assoc_container.hpp>
  3. #include<ext/pb_ds/tree_policy.hpp>
  4. #define int long long
  5. #define mkp make_pair
  6. #define pb push_back
  7. #define ff first
  8. #define ss second
  9. #define debug1(a) cout<<a<<endl;
  10. #define debug2(a,b) cout<<a<<' '<<b<<endl;
  11. #define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
  12. #define rep(i,n) for(int i=0;i<n;i++)
  13. #define repr(i,a,b)for(int i=a;i<b;i++)
  14. #define repre(i,a,b)for(int i=a;i<=b;i++)
  15. #define pi pair<int,int>
  16. #define pii pair<int,pi>
  17. #define mp map<int,int>
  18. #define ump unordered_map<int,int>
  19. #define st set<int>
  20. #define mst multiset<int>
  21. #define pq priority_queue
  22. #define mpq priority_queue<int,vector<int>,greater<int> >
  23. #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  24. using namespace __gnu_pbds;
  25. using namespace std;
  26. typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
  27. typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
  28. //*p.find_by_order(index) return value at index
  29. //p.order_of_key(key) return index
  30.  
  31. int dp[19][10][10];
  32.  
  33. int32_t main()
  34. {
  35. fastio
  36. int l,r;
  37. cin>>l>>r;
  38. rep(i,10)rep(j,10)if(i==j)dp[1][i][j]=1;
  39. repre(l,2,18)
  40. {
  41. repre(i,1,9)
  42. {
  43. repre(j,1,9)
  44. {
  45. if(l==2)
  46. {
  47. if(i==j)dp[l][i][j]=1+dp[l-1][i][j];
  48. continue;
  49. }
  50. if(i==j)dp[l][i][j]=dp[l-1][i][j]+10*(l-2);
  51. else if(j<i)dp[l][i][j]=dp[l][j][j];
  52. else if(j>i)dp[l][i][j]=dp[l][i][i];
  53. }
  54. }
  55. }
  56. return 0;
  57. }
  58.  
Success #stdin #stdout 0s 15248KB
stdin
Standard input is empty
stdout
Standard output is empty