
本文共 3137 字,大约阅读时间需要 10 分钟。
������������
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
������
������������������������������������������������������������������������������������������������������������������������������������������������������������
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������������������������������������������������������
������������
#include#include #include using namespace std;int* x = NULL;int n = 0;long long add = 0;long long mul = 1;void Count(int pos) { // ���������������pos������������ for (int i = pos; i < n; ++i) { // ��������������������������� if (x[i] == 0) continue; int temp_add = add + x[i]; long long temp_mul = mul * x[i]; if (temp_add > temp_mul) { // ������������������������������ Count(i + 1); add = temp_add; mul = temp_mul; } else if (x[i] == 1) { // ������������1��������������������� Count(i + 1); add -= x[i]; mul /= x[i]; // ������1��������������� while (i < n - 1 && x[i] == x[i + 1] && x[i + 1] == 1) { ++i; } // ������������������������ add += x[i]; mul *= x[i]; } else { // ������������������������ add -= x[i]; mul /= x[i]; // ������������������������ while (i < n - 1 && x[i] == x[i + 1]) { ++i; } // ������������������������ add += x[i]; mul *= x[i]; break; } }}int main() { // ������������ cin >> n; x = new int[n]; for (int i = 0; i < n; ++i) { cin >> x[i]; } // ������ sort(x, x + n, greater ()); // ������������������ Count(0); delete[]x; return 0;}
������������
���������������������������������������������������������������������������������������
������������ Count
������������������������������������������������������������������������������������������������������������������
������������������������������������������������������������������������������������������������������������
������������������������������������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
