250pt:

一水...

500pt:
题意:

给你一颗满二叉树的高度,然后找出出最少的不想交的路径并且该路径每个节点只经过一次。

思路:
观察题目中给的图就会发现,其实每形成一个

SRM 585 DIV2-LMLPHP

就会存在一条路径。

我们只要求该满二叉树一共包含多少个即可。

注意奇数与偶数的不同,偶数要忽略第一个根节点,然后后边在+1

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <string>
#include <set>
#include <functional>
#include <numeric>
#include <sstream>
#include <stack>
#include <map>
#include <queue> #define CL(arr, val) memset(arr, val, sizeof(arr)) #define lc l,m,rt<<1
#define rc m + 1,r,rt<<1|1
#define pi acos(-1.0)
#define ll long long
#define L(x) (x) << 1
#define R(x) (x) << 1 | 1
#define MID(l, r) (l + r) >> 1
#define Min(x, y) (x) < (y) ? (x) : (y)
#define Max(x, y) (x) < (y) ? (y) : (x)
#define E(x) (1 << (x))
#define iabs(x) (x) < 0 ? -(x) : (x)
#define OUT(x) printf("%I64d\n", x)
#define lowbit(x) (x)&(-x)
#define Read() freopen("din.txt", "r", stdin)
#define Write() freopen("dout.txt", "w", stdout); #define M 5007
#define N 1007
using namespace std; ll pow2[N];
void init()
{
for (int i = ; i <= ; ++i)
{
pow2[i] = (1LL<<i);
}
}
class TrafficCongestionDivTwo
{
public:
long long theMinCars(int n)
{
init();
ll ans = ;
if (n % == ) //奇数
{
for (int i = ; i < n; ++i)
{
if (i% == ) ans += pow2[i];
}
}
else //偶数
{ ans = 1LL;
for (int i = ; i < n; ++i)
{
if (i% == )
{
ans += pow2[i];
}
}
}
return ans;
} };

1000Pt:

给出一个长度为m的正方形,他的四边分别有不同的颜色的m-1个点均匀分布,然后正方形内有n个黑色的点,然后让你判断过正方形的不同的三条边上的点形成三角形使得该三角形包含所有的黑色的点,问一共有多少种画法?

思路:

我们首先枚举出任意两不同颜色的点看看所有的黑色的点是否其一侧,时间复杂度为O(n*n*m) ,然后枚举三角形判断该三角形是否包含所有黑色点即可。

#line 5 "EnclosingTriangleColorful.cpp"
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <string>
#include <set>
#include <functional>
#include <numeric>
#include <sstream>
#include <stack>
#include <map>
#include <queue> #define CL(arr, val) memset(arr, val, sizeof(arr)) #define lc l,m,rt<<1
#define rc m + 1,r,rt<<1|1
#define pi acos(-1.0)
#define ll long long
#define L(x) (x) << 1
#define R(x) (x) << 1 | 1
#define MID(l, r) (l + r) >> 1
#define Min(x, y) (x) < (y) ? (x) : (y)
#define Max(x, y) (x) < (y) ? (y) : (x)
#define E(x) (1 << (x))
#define iabs(x) (x) < 0 ? -(x) : (x)
#define OUT(x) printf("%I64d\n", x)
#define lowbit(x) (x)&(-x)
#define keyTree (chd[chd[root][1]][0])
#define Read() freopen("din.txt", "r", stdin)
#define Write() freopen("dout.txt", "w", stdout); #define M 100
#define N 307 using namespace std; int dx[]={-,,,};
int dy[]={,,-,};//懈芯芯斜胁小褋褉 const int inf = 0x7f7f7f7f;
const int mod = ;
const double eps = 1e-; struct Point
{
double x,y;
Point(){}
Point(double tx = ,double ty = ) : x(tx),y(ty){}
};
typedef Point Vtor;
//鍚戦噺鐨勫姞鍑忎箻闄�
Vtor operator + (Vtor A,Vtor B) { return Vtor(A.x + B.x,A.y + B.y); }
Vtor operator - (Point A,Point B) { return Vtor(A.x - B.x,A.y - B.y); }
Vtor operator * (Vtor A,double p) { return Vtor(A.x*p,A.y*p); }
Vtor operator / (Vtor A,double p) { return Vtor(A.x/p,A.y/p); }
bool operator < (Point A,Point B) { return A.x < B.x || (A.x == B.x && A.y < B.y);}
int dcmp(double x){ if (fabs(x) < eps) return ; else return x < ? - : ; }
bool operator == (Point A,Point B) {return dcmp(A.x - B.x) == && dcmp(A.y - B.y) == ; }
//鍚戦噺鐨勭偣绉紝闀垮害锛屽す瑙�
double Dot(Vtor A,Vtor B) { return A.x*B.x + A.y*B.y; }
double Length(Vtor A) { return sqrt(Dot(A,A)); }
double Angle(Vtor A,Vtor B) { return acos(Dot(A,B)/Length(A)/Length(B)); }
double Cross(Vtor A,Vtor B) { return A.x*B.y - A.y*B.x; }
double Area2(Point A,Point B,Point C) { return Cross(B - A,C - A); } bool UL[N][N],UR[N][N],DL[N][N],DR[N][N];
bool LR_up[N][N],LR_dw[N][N],UD_L[N][N],UD_R[N][N]; class EnclosingTriangleColorful
{
public:
int getNumber(int m, vector <int> x, vector <int> y)
{
int n = x.size();
//鍑轰簨璇濅笁瑙掑舰鐨勮竟
//涓婏紝宸︼紝鍙�
for (int i = ; i < m; ++i)
{
for (int j = ; j < m; ++j)
{
bool f1 = true ,f2 = true;
for (int k = ; k < n; ++k)
{
Point A(i,m);
Point B(,j);
Point C(m,j);
if (Cross(B - A,Point(x[k],y[k]) - A) < ) f1 = false;
if (Cross(C - A,Point(x[k],y[k]) - A) > ) f2 = false;
}
UL[i][j] = f1; UR[i][j] = f2;
}
}
//涓�宸︼紝鍙�
for (int i = ; i < m; ++i)
{
for (int j = ; j < m; ++j)
{
bool f1 = true ,f2 = true;
for (int k = ; k < n; ++k)
{
Point A(i,);
Point B(,j);
Point C(m,j);
if (Cross(B - A,Point(x[k],y[k]) - A) > ) f1 = false;
if (Cross(C - A,Point(x[k],y[k]) - A) < ) f2 = false;
}
DL[i][j] = f1; DR[i][j] = f2;
}
}
//宸︼紝鍙�
for (int i = ; i < m; ++i)
{
for (int j = ; j < m; ++j)
{
bool f1 = true ,f2 = true;
for (int k = ; k < n; ++k)
{
Point A(,i);
Point B(m,j);
if (Cross(B - A,Point(x[k],y[k]) - A) < ) f1 = false;
if (Cross(B - A,Point(x[k],y[k]) - A) > ) f2 = false;
}
LR_up[i][j] = f1; LR_dw[i][j] = f2;
}
}
//涓婏紝涓�
for (int i = ; i < m; ++i)
{
for (int j = ; j < m; ++j)
{
bool f1 = true ,f2 = true;
for (int k = ; k < n; ++k)
{
Point A(i,m);
Point B(j,);
if (Cross(B - A,Point(x[k],y[k]) - A) > ) f1 = false;
if (Cross(B - A,Point(x[k],y[k]) - A) < ) f2 = false;
}
UD_L[i][j] = f1; UD_R[i][j] = f2;
}
} int ans = ;
//涓婂乏鍙�
for (int i = ; i < m; ++i)
{
for (int j = ; j < m; ++j)
{
for (int k = ; k < m; ++k)
{
if (UL[i][j] && UR[i][k] && LR_up[j][k]) ans++;
}
}
}
//涓嬪乏鍙�
for (int i = ; i < m; ++i)
{
for (int j = ; j < m; ++j)
{
for (int k = ; k < m; ++k)
{
if (DL[i][j] && DR[i][k] && LR_dw[j][k]) ans++;
}
}
}
//宸︿笂涓�
for (int i = ; i < m; ++i)
{
for (int j = ; j < m; ++j)
{
for (int k = ; k < m; ++k)
{
if (UL[j][i] && DL[k][i] && UD_L[j][k]) ans++;
}
}
}
//鍙充笂涓�
for (int i = ; i < m; ++i)
{
for (int j = ; j < m; ++j)
{
for (int k = ; k < m; ++k)
{
if (UR[j][i] && DR[k][i] && UD_R[j][k]) ans++;
}
}
}
return ans; } }; // Powered by FileEdit
// Powered by TZTester 1.01 [25-Feb-2003]
// Powered by CodeProcessor
05-11 15:25