Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <time.h>
  3. using namespace std;
  4. typedef long long LL;
  5. const LL inf = 4*(1e9) + 10;
  6. const int dx[] = {0, 0, -1, 1};
  7. const int dy[] = {1, -1, 0, 0};
  8. const int MOD = 1000000007;
  9. const int NMAX = 100005;
  10.  
  11. vector<int> G[NMAX];
  12. bool viz[NMAX];
  13.  
  14. /*
  15. void bfs(int v){
  16. queue<int> Q;
  17. memset(viz, 0, sizeof(viz));
  18. Q.push(v);
  19. viz[v] = 1;
  20. while(!Q.empty()){
  21. int cur = Q.top();
  22. for(auto el: G[cur]){
  23. if(!viz[el]){
  24. viz[el] = 1;
  25. Q.insert(el);
  26. }
  27.  
  28. }
  29. }
  30.  
  31.  
  32. }
  33. */
  34.  
  35. void check(vector<int> set){
  36. // Computations
  37.  
  38. for(auto el: set){
  39. cout<<el<<" ";
  40. }
  41. cout<<"\n";
  42. }
  43.  
  44. void subsets(int n){
  45. vector<int> curr;
  46. for(int i=0; i<(1<<n); ++i){
  47. curr.clear();
  48. for(int j=0; j<n; ++j){
  49. if(i & (1<<j)){
  50. curr.push_back(j);
  51. }
  52. }
  53. check(curr);
  54. }
  55. }
  56.  
  57. void perms(int n){
  58. vector<int> perm;
  59. for(auto i=0; i<n; ++i){
  60. perm.push_back(i);
  61. }
  62. do{
  63. check(perm);
  64. }while(next_permutation(perm.begin(), perm.end()));
  65. }
  66.  
  67. vector<int> prms;
  68. int np[NMAX];
  69.  
  70. void sieve(){
  71. for(int i=2; i<=NMAX-1; ++i){
  72. if(!np[i]){
  73. prms.push_back(i);
  74. for(int j=2*i; j<=NMAX-1; j+=i){
  75. np[j] = 1;
  76. }
  77. }
  78.  
  79. }
  80. }
  81.  
  82.  
  83. int x, n;
  84. int dp[1555][50];
  85.  
  86. int main(){
  87. cin>>n;
  88.  
  89. vector<int> pws;
  90. int c = 1;
  91. int i = 1;
  92. while(c <= 1000){
  93. pws.push_back(c);
  94. i++;
  95. c = 1;
  96. for(int j=1; j<=n && c < 1005; ++j){
  97. c = c*i;
  98. }
  99. }
  100. for(auto el: pws){
  101. //cout<<el<<"\n";
  102. }
  103.  
  104. for(int i=0; i<=pws.size(); ++i){
  105. dp[0][i] = 1;
  106. }
  107. for(int i=1; i<=x; ++i){
  108. for(int j=1; j<=pws.size(); ++j){
  109. if(i - pws[j-1] >= 0){
  110. cout<<i<< " " <<i - pws[j-1]<<"\n";
  111. dp[i][j] += dp[i - pws[j-1]][j];
  112. }
  113. }
  114. }
  115. cout<<dp[x][pws.size()];
  116.  
  117.  
  118. /*
  119. for(int i=1; i<=m; ++i){
  120. cin>>a>>b;
  121. G[a].push_back(b);
  122. G[b].push_back(a);
  123. }
  124. */
  125.  
  126. return 0;
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement