-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmixturesSPOJ_BottomUp.cpp
More file actions
55 lines (49 loc) · 1 KB
/
Copy pathmixturesSPOJ_BottomUp.cpp
File metadata and controls
55 lines (49 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <stack>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <sstream>
#include <iomanip>
using namespace std;
vector<int> m = {18, 19};
vector<vector<int> >dp(100, vector<int>(100, 0));
int sum(int x, int y){
int temp = 0;
int i = x;
while(i <= y){
temp += m[i];
temp %= 100;
i++;
}
return temp;
}
int32_t main()
{
int i = 0, j = 2;
for(int j = 1 ; j <= 2 ; j++){
for(int i = j-1 ; i >= 0 ; i--){
dp[i][j] = INT_MAX;
for(int k = i ; k <= j ; k++){
dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + sum(i, k) * sum(k+1, j));
}
}
}
cout<<dp[0][2]<<endl;
}