fork(1) download
  1. #include<iostream>
  2. #include<stdio.h>
  3. #include<algorithm>
  4. #include<math.h>
  5. #include<bits/stdc++.h>
  6. #include<stack>
  7. #include<queue>
  8. #include<list>
  9. #include<vector>
  10. #include<bitset>
  11. // #include < unordered_map >
  12. #include <ext/pb_ds/assoc_container.hpp>
  13. #include <ext/pb_ds/tree_policy.hpp>
  14. // #include "boost/algorithm/string.hpp"
  15. #define fio ios_base::sync_with_stdio(false)
  16. #define mod 1000000007
  17. #define mod1 mod
  18. #define mod2 100000009
  19. #define li long long int
  20. #define ll int
  21. #define readi(x) scanf("%d",&x)
  22. #define reads(x) scanf("%s", x)
  23. #define readl(x) scanf("%I64d",&x)
  24. #define rep(i,n) for(i=0;i<n;i++)
  25. #define revp(i,n) for(i=(n-1);i>=0;i--)
  26. #define myrep1(i,a,b) for(i=a;i<=b;i++)
  27. #define myrep2(i,a,b) for(i=b;i>=a;i--)
  28. #define pb push_back
  29. #define mp make_pair
  30. #define fi first
  31. #define sec second
  32. #define MAXN 1000000000000000
  33. #define MINN -1000000000000000000
  34. #define pii pair<ll,ll>
  35. #define pdd pair<double,double>
  36. #define pic pair<int,char>
  37. #define N 400050
  38. #define lgn 20
  39. #define ddouble long double
  40. #define minus minu
  41. #define PI 3.1415926535
  42.  
  43.  
  44. // #define INTMAX 200000000
  45.  
  46. // using namespace boost;
  47. // #define si short int
  48.  
  49. using namespace std;
  50. using namespace __gnu_pbds;
  51. typedef priority_queue<ll, vector<ll> > max_pq;
  52. typedef priority_queue<char, vector<char> , greater<char > > min_pq;
  53. ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
  54. string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}
  55.  
  56. // typedef priority_queue<pair < ll , pair < pii , ll > > , vector<pair < ll , pair < pii , ll > > > ,greater<pair < ll , pair < pii , ll > > > > min_pq;
  57.  
  58. typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
  59. typedef priority_queue< char , vector<char> > max_pqc;
  60. // typedef priority_queue<ll, vector<ll > , greater < ll > > min_pq;
  61.  
  62. // <<<MAIN BINARY SEARCH ON ANSWER BHUL KYUN JAATA HUN >>>
  63. ll dp[ N ];
  64.  
  65.  
  66. int main()
  67. {
  68. ios::sync_with_stdio(false);
  69. cin.tie(NULL);
  70. #ifndef ONLINE_JUDGE
  71. freopen("input.txt","r",stdin);
  72. freopen("output.txt","w",stdout);
  73. #endif
  74.  
  75. dp[1] = 1;
  76. dp[2] = 3;
  77. for ( ll i = 3; i <= 100 ; i ++)
  78. {
  79. ll min_moves=INT_MAX, optimalpick = 0;
  80. for ( ll j = 2; j < i ; j ++)
  81. {
  82. if ( (dp[j-1]+dp[i-j]+2) < min_moves )
  83. {
  84. min_moves = (dp[j-1]+dp[i-j]+2);
  85. optimalpick = j;
  86. }
  87. }
  88. dp[i] = min_moves;
  89. cout << dp[i] <<":" << optimalpick << endl;
  90. }
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100. //now u have the ans
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108. }
  109.  
  110.  
  111.  
Success #stdin #stdout 0s 16792KB
stdin
Standard input is empty
stdout
4:2
6:2
7:2
9:2
10:2
12:2
13:2
15:2
16:2
18:2
19:2
21:2
22:2
24:2
25:2
27:2
28:2
30:2
31:2
33:2
34:2
36:2
37:2
39:2
40:2
42:2
43:2
45:2
46:2
48:2
49:2
51:2
52:2
54:2
55:2
57:2
58:2
60:2
61:2
63:2
64:2
66:2
67:2
69:2
70:2
72:2
73:2
75:2
76:2
78:2
79:2
81:2
82:2
84:2
85:2
87:2
88:2
90:2
91:2
93:2
94:2
96:2
97:2
99:2
100:2
102:2
103:2
105:2
106:2
108:2
109:2
111:2
112:2
114:2
115:2
117:2
118:2
120:2
121:2
123:2
124:2
126:2
127:2
129:2
130:2
132:2
133:2
135:2
136:2
138:2
139:2
141:2
142:2
144:2
145:2
147:2
148:2
150:2