poj 1084 Brainman

```#include <stdio.h>
#include <limits.h>

long long Count = 0;
const int MAX_N = 1000 + 10;
long long A[MAX_N], L[MAX_N], R[MAX_N];

void Merge(long long A[], int p, int q, int r)
{
int i, j, k;

int n1 = q - p + 1;
int n2 = r - q;

for (int i = 0; i < n1; ++i)
L[i] = A[p + i];
for (int j = 0; j < n2; ++j)
R[j] = A[q + j + 1];

i = j = 0;
k = p;
L[n1] = INT_MAX;
R[n2] = INT_MAX;

while (k <= r)
{
if (L[i] > R[j])
{
A[k++] = R[j++];
Count += n1 - i;
}
else
A[k++] = L[i++];
}
}

void Merge_Sort(long long A[], int p, int q)
{
int r = (p + q) / 2;

if (p < q)
{
Merge_Sort(A, p, r);
Merge_Sort(A, r + 1, q);
Merge(A, p, r, q);
}
}

int main()
{
int n;
int Scenario = 0;

scanf("%d", &n);
for (int i = 0; i < n; ++i)
{
int Num;

scanf("%d", &Num);

Count = 0;
Scenario++;
for (int i = 0; i < Num; ++i)
scanf("%lld ", &A[i]);

Merge_Sort(A, 0, Num - 1);
printf("Scenario #%d:\n%lld\n\n", Scenario, Count);
}

return 0;
}```

POJ 1804 Brainman(5种解法，好题，【暴力】，【归并排序】，【线段树单点更新】，【树状数组】，【平衡树】)

Brainman Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 10575   Accepted: 5489 Description BackgroundRaymond Babbitt drives his brother Charlie mad. Recently Raymond counted 246 toothpicks spilled all over the floor in an instant just b

【POJ 1084】 Square Destroyer

[题目链接] http://poj.org/problem?id=1084 [算法] 迭代加深 [代码] #include <algorithm> #include <bitset> #include <cctype> #include <cerrno> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #inclu

POJ 1084

WA了好久,第一次用重覆盖的模型做题.感觉这题有个陷阱,那就是当去掉某些边后,若因为这个边去掉而被破环的正方形还存在,那么就会造成覆盖不完全,WA. 所以,在去掉边后,必定有些正方形是不存在的,须重新计算.另外,计算一个正方形有哪些边也很困难. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int

(中等) POJ 1084 Square Destroyer , DLX+可重复覆盖。

Description The left figure below shows a complete 3*3 grid made with 2*(3*4) (=24) matchsticks. The lengths of all matchsticks are one. You can find many squares of different sizes in the grid. The size of a square is the length of its side. In the