250pt:

一水...

500pt:
题意:

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

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

就会存在一条路径。

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

注意奇数与偶数的不同,偶数要忽略第一个根节点,然后后边在+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

SRM 585 DIV2的更多相关文章

  1. SRM 657 DIV2

    -------一直想打SRM,但是感觉Topcoder用起来太麻烦了.题目还是英文,不过没什么事干还是来打一打好了.但是刚注册的号只能打DIV2,反正我这么弱也只适合DIV2了.. T1: 题目大意: ...

  2. Topcoder Srm 673 Div2 1000 BearPermutations2

    \(>Topcoder \space Srm \space 673 \space Div2 \space 1000 \space BearPermutations2<\) 题目大意 : 对 ...

  3. Topcoder Srm 671 Div2 1000 BearDestroysDiv2

    \(>Topcoder \space Srm \space 671 \space Div2 \space 1000 \space BearDestroysDiv2<\) 题目大意 : 有一 ...

  4. 记第一次TopCoder, 练习SRM 583 div2 250

    今天第一次做topcoder,没有比赛,所以找的最新一期的SRM练习,做了第一道题. 题目大意是说 给一个数字字符串,任意交换两位,使数字变为最小,不能有前导0. 看到题目以后,先想到的找规律,发现要 ...

  5. Topcoder srm 632 div2

    脑洞太大,简单东西就是想复杂,活该一直DIV2; A:水,基本判断A[I]<=A[I-1],ANS++; B:不知道别人怎么做的,我的是100*N*N;没办法想的太多了,忘记是连续的数列 我们枚 ...

  6. SRM 638 Div2

    2333... 因为TC过少的参与者.加上不断fst 我掉了div2该. 幸运的是完成的背div1该.. 250 水的问题 500 水的问题.. 直接bfs扩展即可了 注意判重.  我还用康托展开了真 ...

  7. SRM 592 DIV2 报告

    昨天下午查看邮箱,看到了topcoder的SRM比赛通知和cf的比赛通知,当时什么也不想做,心里空荡荡的,忽然就想参加一下,试试看.吃完晚饭回来一看,就剩十几分钟了,匆忙把平台下了,就开始等待比赛开始 ...

  8. SRM 670 div2 A B C div1 A(贪心,子问题合并)

    A Cdgame brute force... B Drbalance 贪心,每次选最前面的-变成+,相当于后面所有的负值+2. C Treestrat 考虑集中去抓一个Red Token,以这个To ...

  9. topcpder SRM 664 div2 A,B,C BearCheats , BearPlays equalPiles , BearSorts (映射)

    A题,熊孩子测视力,水题,题意就是判断一下两个数对应位不相同的数字有多少个. #include<bits/stdc++.h> using namespace std; class Bear ...

随机推荐

  1. [css]演示:纯CSS实现的右侧底部简洁悬浮效果

    <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <meta name ...

  2. 如何学习 cocos2d-x ?

    发表于 04/23/2014 作者 zrong — 24 条评论 ↓ 11,687 次查看 本站文章除注明转载外,均为本站原创或者翻译. 本站文章欢迎各种形式的转载,但请18岁以上的转载者注明文章出处 ...

  3. struts2的action如果返回null会怎样

    action return nullresponse里直接写要返回的东西, 返回null,就是说视图不跳转到任何地方,当然就出现空白页面了.如果想出现页面就需要在struts.xml文件里面配置res ...

  4. java中的socket编程

    Socket,又称为套接字,Socket是计算机网络通信的基本的技术之一.如今大多数基于网络的软件,如浏览器,即时通讯工具甚至是P2P下载都是基于Socket实现的.本文会介绍一下基于TCP/IP的S ...

  5. xpath定位方法小结(转载)

    1.实例化一个浏览器WebDriver driver = new FirefoxDriver(); 2.driver.get() get传参数到浏览器中 3.常用定位方法webelement XX=d ...

  6. Object 对象有哪些方法?

    这个不看还真不一定能说全,请养成良好的阅读源码和JDK文档的习惯. 总结一下:一共11个,wait的3个+notify的2个,hashCode和equals还有toString共3个,然后clone和 ...

  7. Pandas介绍

    pandas是python非常好用的一个数据结构包,包含有许多数据操作的方法,能够让你快速简便的提取和保存数据,节省你在这块的数据流操作耗时,从而让你更加专注于逻辑的设计和算法的设计.很多算法的相关库 ...

  8. 各大互联网企业Java面试题汇总,看我如何成功拿到百度的offer

    前言 本人Java开发,5年经验,7月初来到帝都,开启面试经历,前后20天左右,主面互联网公司,一二线大公司或者是融资中的创业公司都面试过,拿了一些offer,其中包括奇虎360,最后综合决定还是去百 ...

  9. Excel 26机制转换

    [问题描述] 在Excel中,列的名称是这样一个递增序列:A.B.C.….Z.AA.AB.AC.….AZ.BA.BB.BC.….BZ.CA.….ZZ.AAA.AAB….我们需要将上述列名序列和以下自然 ...

  10. Warm up---hdu4612(缩点,树的直径)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4612 给一个无向图, 加上一条边后,求桥最少有几个: 那我们加的那条边的两个顶点u,v:一定是u,v之 ...