相关分类: Java技术 C/C++ VB delphi
  • 打地鼠游戏(堆维护)

    伟大的2320学长特别喜欢打地鼠游戏,这个游戏开始后,会在地板上冒出一些地鼠来,你可以用榔头去敲击这些地鼠,每个地鼠被敲击后,将会增加相应的游戏分值。可是,所有地鼠只会在地上出现一段时间(而且消失后再也不会出现),每个地鼠都在0时刻冒出,但停留的时间可能...

    2018-07-25 13:00:46

  • minimum-depth-of-binary-tree

    题目描述: Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 解题思路: 递归解题方法: (1)左儿子与右儿子皆不为NULL。父节点的最小深度,等于...

    2018-07-25 13:00:45

  • 洛谷P4779 【模板】单源最短路径(标准版)

    题意 。。。求最短路 Sol 前几天写dijkstra的时候没打vis标记居然A了,然后天真的我就以为Dijkstra不用打标记。 事实上dijkstra真的不用打标记,只不过会被卡成SPFA的复杂度 #includecstdio #include algorithm #include cstring #include ext/pb_ds/priority_queue.hp...

    2018-07-24 07:50:55

  • C++类模版外部实现标准写法

    #include iostream using namespace std;template typename T class Person{ public : T age; public : explicit Person(T newAge); void show();}; //类模版函数在外部定义时,必须加上template标识template typename T Person T ::Person(T newAge){ this -age = new...

    2018-07-24 07:50:54

  • TCP/IP 学习 --- 4(linux网络基础api)

    1 sockaddr_in、sockaddr_in6和sockadd_un等都可以强制转换为sockaddr. 2 IP地址是电分十进制形式的字符串,但是在网络中使用的是unsigned int类型的数才能使用。 in_addr_t inet_addr(const char* strptr); 返回的是ipv4的usigned int类型的地址。 int inet_aton(cons...

    2018-07-24 07:50:52

  • 愤怒的小鸟P2831

    题意: 有 n 个坐标,求用抛物线 y=ax^2+bx 将它们全部穿过所需的最少个数 思路: 状压dp 另外对于被同一条抛物线穿过的两点,有: a=(x2 y1-x1 y2)/(x1 x2(x1-x2), b=(x1 x1 y2-x2 x2 y1)/(x1 x2*(x1-x2)) code: #include cstdio #include cstring #include algorith...

    2018-07-24 07:50:49

  • 洛谷P2765 魔术球问题(贪心 最大流)

    题意 已经很简洁了吧。 假设有n根柱子,现要按下述规则在这n根柱子中依次放入编号为1,2,3,...的球。 (1)每次只能在某根柱子的最上面放球。 (2)在同一根柱子中,任何2个相邻球的编号之和为完全平方数。 试设计一个算法,计算出在n根柱子上最多能放多少个球 Sol...

    2018-07-23 05:31:09

  • UVA 1585 Score (c++ )(字符串处理)

    题目大意是给一个由O和X组成的字符串,而这个字符串的得分是由连续的O的数目来统计的。比如OOXXOOXXOO的得分就是1+2+0+0+1+2+0+0+1+2=9。了解了题目大意就好解决了。 #include iostream #include cstdio #include string #include cstring #include cmath #include alg...

    2018-07-23 05:31:08

  • 洛谷P2770 航空路线问题(费用流)

    题意 $n$个点从左向右依次排列,有$m$条双向道路 问从起点到终点,再从终点回到起点,在经过的点不同的情况下最多能经过几个点 Sol 首先,问题可以转化为求两条互不相交的路径,使得点数最多 为了满足流量的限制,肯定会想到拆点,把每个点拆为两个,连流量为$1$,费用...

    2018-07-23 05:31:07

  • GCD LCM 素数 快速幂

    1.********** GCD( 最大公约数) 代码实现(复杂度为O(logn)) int gcd ( int a, int b){ return b ? gcd ( b , a % b ) : a ; } 2.*********** LCM (最小公倍数) lcm(a,b) = a * b / gcd(a,b); 3.******** 素数 代码实现(复杂度为O(logn)) 函数isprime返回值中 值...

    2018-07-23 05:31:05

2