It was just a good time last night that TC had a game from. So after a while, I found that my coding habits were very bad without ide. When debugging 1000pt, I couldn't even connect the brackets... Code writing is messy and debugging is difficult! This bad problem has to be changed! If I had not done the problem for one night, I gave 20 points to my sister!
250pt: X is either 0 or 1, and the given coefficient AI is also 0 or 1. So you just need to scan it.
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <map>
using namespace std;
class BinaryPolynomialDivTwo {
public:
int countRoots(vector <int> a) {
int len = a.size();
int i, ans, cnt = 0;
if(a[0] == 0) cnt++;
for(ans = 0, i = 0; i < len; ++i) {
ans += a[i];
}
ans %= 2;
if(ans == 0) cnt++;
return cnt;
}
};
PT: the idea is to replace the data with the int type, and then store the data in a two-dimensional array. First, sort the data in ascending order of each row, and then find the largest and summation column.
PS: I started to write this question without thinking clearly. I changed it several times in the middle and reviewed it! Review!
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <map>
using namespace std;
class RollingDiceDivTwo {
public:
int minimumFaces(vector <string> rolls) {
int i, l1, j;
int l2 = 0, ans = 0;
int m[100][100],a[50], t;
l1 = rolls.size();
for(i = 0; i < l1; ++i) {
l2 = rolls[i].size();
for(j = 0; j < l2; ++j) {
t = rolls[i][j] - '0';
a[j] = t;
}
sort(a, a + l2);
for(j = 0; j < l2; ++j)
m[i][j] = a[j];
}
for(j = 0; j < l2; ++j) {
t = 0;
for(i = 0; i < l1; ++i) {
t = max(t, m[i][j]);
}
ans += t;
}
return ans;
}
};
1000pt: sort by size. A [I] indicates the sum of all numbers before I. F [I] indicates the maximum profit of the left and right numbers before I.
F [I] = max (F [I], (s [I]-s [J] + F [J])/(I-j + 1 ));
After reading the ideas of the pass, I wrote a piece of code.
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
class MergersDivTwo {
public:
double a[100], b[100], f[100];
double findMaximum(vector <int> revenues, int k) {
sort(revenues.begin(), revenues.end());
int len = revenues.size();
int i, j;
for(i = 1; i <= len; ++i) {
b[i] = revenues[i-1];
a[i] = a[i-1] + b[i];
}
for(i = 1; i <= len; ++i) {
f[i] = -1e9;
if(i >= k) f[i] = a[i]/i;
for(j = i - k + 1; j >= 1; --j) {
f[i] = max(f[i], (a[i] - a[j] + f[j])/(i-j+1));
}
}
return f[len];
}
};
<%:testing-code%>
//Powered by KawigiEdit 2.1.8 (beta) modified by pivanof!
We strongly recommend that you use the kawigiedit plug-in, which is much better than standard...