自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

L-qf 的博客

ACM之缘

  • 博客(134)
  • 收藏
  • 关注

原创 UVA-11572 Unique Snowflakes (STL)

Emily the entrepreneur has a cool business idea: packaging and selling snowflakes. She has devised a machine that captures snowflakes as they fall, and serializes them into a stream of snowflakes that...

2018-09-07 09:43:28 169

原创 UVA-11134 Fabled Rooks (贪心)

We would like to place n rooks, 1 ≤ n ≤ 5000, on a n × n board subject to the following restrictions• The i-th rook can only be placed within the rectangle given by its left-upper corner (xli , yli)...

2018-09-05 17:46:48 206

原创 UVA-1152 (二分) 4 Values whose Sum is 0

The SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute how many quadruplet (a, b, c, d) ∈ A × B × C × D are such that a + b + c + d = 0. In the following,...

2018-09-04 17:00:17 156

原创 UVA-1605 Building for UN

The United Nations has decided to build a new headquarters in Saint Petersburg, Russia. It will have a form of a rectangular parallelepiped and will consist of several rectangular floors, one on top o...

2018-09-03 21:16:24 121

原创 UVA-120Stacks of Flapjacks

Stacks and Queues are often considered the bread and butter of data structures and find use in architecture, parsing, operating systems, and discrete event simulation. Stacks are also important in the...

2018-09-03 20:46:39 284

原创 竞赛篇-----二分查找

/*二分查找,左闭右开区间注意查找的数组一定是有序的*/#include<cstdio>#include<iostream>#include<algorithm>#define N 1005using namespace std;int a[N];int bsearch(int *a,int x,int y,int val) { int ...

2018-08-28 20:15:58 271

原创 竞赛篇----归并排序顺带求逆序数

/*归并排序实现 求逆序数 O(nlogn)*/#include<cstdio>#include<iostream>#include<algorithm>#define N 1005using namespace std;int a[N],t[N],cnt;void merge_sort(int *a,int x,int y,int *t)...

2018-08-28 20:11:42 159

原创 竞赛篇-----最大连续和问题

1)首先最简单的就是模拟时间复杂度是O(n^3)/*最大连续和问题O(n^3)*/#include<cstdio>#include<iostream>using namespace std;int main() { int a[1005],n,sum,ans; while(~scanf("%d",&n)) { for(int i=1; i...

2018-08-28 18:37:20 159

原创 HDU-2829 Lawrence(dp+四边形优化)

题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2829#include<cstdio>#include<iostream>#include<cstring>#define N 1005#define inf 0x3f3f3f3f#include<algorithm>#define ll...

2018-08-27 20:33:02 197

原创 UVA-10003 Cutting Sticks (动规-四边形不等式dp)

题目:          You have to cut a wood stick into pieces. The most affordable company, The Analog Cutting Machinery, Inc. (ACM), charges money according to the length of the stick being cut. Their proc...

2018-08-27 09:38:09 182

原创 HDU-2545树上战争(找根节点)

题目信息:http://acm.hdu.edu.cn/showproblem.php?pid=2545#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>using namespace std;struct pine { double s,e;...

2018-08-24 15:41:35 273

原创 HDU-2540 遮挡判断(贪心+数学)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2540#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>using namespace std;struct pine { double s,e;...

2018-08-24 09:30:13 172

原创 HDU-2539 点球大战(字符串处理)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2539#include<cstdio>#include<iostream>#include<cstring>using namespace std;int main() { int n,sum; string s1[105]; while(~sca...

2018-08-23 19:41:26 228

原创 HDU-2526 浪漫手机(下一行的每个字符由上一行的顶部三个决定,)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2526思路: 自己找出范围是m<=1000,每行的左右都是0,但是不能输出,上一行的字符决定下一行。#include<cstdio>#include<iostream>#include<cstring>using namespace std;i...

2018-08-23 11:40:57 142

原创 HDU-2515 Yanghee 的算术(数学计算)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2515思路:将数表中的数存放在a数组中            先算出第一个数,然后用0~n-2个数表中的数依次算出剩下的n-1个数,            计算第一个数的方法有很多,大致意思是找出三个数表中的数联立方程算出第一个数,我这里用的是(a[0]+a[1]-a[n-1])/2  ...

2018-08-23 09:30:49 375

原创 HDU-5873 Football Games(思维题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5873#include<cstdio>/*得分从小到大排序,对于当前i,与之前的i-1支队伍比赛完之后,所有的比赛的总得分至少是(i-1)*i每场比赛都产生2分,打了(i-1)*i/2场,也就是i*(i-1)分最后n场的总分为n*(n-1)*/#include<i...

2018-08-22 11:11:12 230

原创 HDU-2527 Safe Or Unsafe(哈夫曼树)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2527#include<cstdio>#include<iostream>#include<cstring>#include<queue>using namespace std;int main() { priority_queue&lt...

2018-08-21 20:24:59 239

原创 HDU-2523SORT AGAIN(水!注意读题!!不然会tle)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2523代码:/*注意题上说了有k-1个不同!!!!的组合数小于它,所以要判重 还有就是 题上说了每个数小于2000,所以组合数结果肯定小于2000,即结果在2000里判断 不能用sort排序,结果太大,会tle! */#include<cstdio>#include&l...

2018-08-21 09:17:03 180

原创 HDU-2512 一卡通大冒险(第二类斯特林数)

借鉴:https://blog.csdn.net/flynn_curry/article/details/59156101题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2512思路:已知第一类斯特灵数:将p个物体排成k个非空循环排列的方法数。s(p,0)=0 ,p>=1 ;s(p,p)=1  ,p>=0。递推式:s(p,k...

2018-08-20 11:15:41 131

原创 HDU-2522A simple problem (1/n 的循环小数)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2522代码:#include<cstdio>#include<iostream>#include<cmath>#include<cstring>using namespace std;bool vis[200005];int main...

2018-08-20 09:34:17 159

原创 HDU-2612 Find a way (广搜)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2612#include<cstdio>#include<iostream>#include<algorithm>#include<queue>#include<cstring>#define N 210#define inf ...

2018-08-19 16:27:25 144

原创 HDU-2546 饭卡(动态规划--01背包)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2546#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#define N 1005using namespace std;int main() {...

2018-08-19 15:24:52 429

原创 HDU-1033Edge(恶心的题目。。。。。)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1033题意就是四个方向的转。。。。水题!!!!看代码。代码:#include<cstdio>#include<iostream>#include<algorithm>#define N 205#include<cstring>usi...

2018-08-19 11:08:49 208

原创 HDU-1598 find the most comfortable road(最小生成树 Prim)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1598#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#define N 210#define M 1010#define inf 0x3f3f3...

2018-08-18 20:42:17 107

原创 HDU-1875 畅通工程再续(最小生成树-Prim)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1875这题我卡了10遍。。。最终ac代码:#include<cstdio>#include<iostream>#include<cmath>#define N 110#include<cstring>#define inf 0x3f...

2018-08-18 20:15:09 130

原创 HDU-3371 Connect the Cities(最小生成树-克鲁斯卡尔)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3371题意:就是给出你已知的m条路的长度和k个联通分量,让你找出最小的代价让他们都相通。#include<cstdio>#include<iostream>#include<algorithm>#include<cstring>#defi...

2018-08-18 20:13:15 152

原创 HDU-1301 Jungle Roads (最小生成树-Prim)【0MS】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1301#include<iostream>#include<cstdio>#include<cstring>#define inf 0x3f3f3f3fusing namespace std;int map[27][27],dis[27];int n...

2018-08-17 09:18:19 102

原创 HDU-1198 Farm Irrigation (并查集)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1198并查集找几个不是同一个联通的#include<cstdio>#include<iostream>#define N 55using namespace std;int per[N][N];char map[N][N];int n,m;char a[1...

2018-08-16 21:09:38 102

原创 POJ-1258 Agri-Net (Prim)

题目链接:http://poj.org/problem?id=1258雷同与 poj1789 求最小生成树的路径代码:#include<cstdio>#include<cstring>#define N 105#define inf 0x3f3f3f3f#include<algorithm>using namespace std;int...

2018-08-16 15:13:18 113

原创 POJ-2485 Highways (Prim )

题目链接:http://poj.org/problem?id=2485题意:求最小生成树中最长的路径#include<cstdio>#include<iostream>#include<cstring>#define inf 0x3f3f3f3f#define N 505using namespace std;int map[N][N],d...

2018-08-16 14:41:13 102

原创 POJ-1789Truck History(Prim简单模板)

题目链接:http://poj.org/problem?id=1789题意:n个车牌号,刚开始只有一个车牌,其他车牌都是由一个车牌直接或间接产生 。一个车牌到另一个车牌的产生权值是它们之间的数字不同的个数,问产生的最小的边权和 //最小生成树代码:#include<cstdio>#include<iostream>#define inf 0x3f3f3f3...

2018-08-16 10:48:57 90

原创 HDU-1058Humble Numbers

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1058本题思路很简单:就是用2,3,5,7循环来 求第i个f[i],第i个f[i]必定等于 前i-1个数中其中一个数与{2,3,5,7}中 其中一个的乘积,于是答案就出来了,就是取从1开始取与2,3,5,7相乘,取最小的,取了一个对应指针就往前移一位#include<cstdio&...

2018-08-15 21:14:29 110

原创 HDU-1032The 3n + 1 problem

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1032注意:输入不一定保证第一个数就比第二个数小,数据较弱,直接暴力!#include<cstdio>#include<iostream>#define N 1000005using namespace std;int fun(int a,int b) { i...

2018-08-15 15:52:41 181

原创 HDU-1028Ignatius and the Princess III

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=10280MS#include<cstdio>#include<iostream>#include<cstring>#define N 125using namespace std;int dp[N];void init() { memset(d...

2018-08-15 15:05:04 116

原创 HDU-1024(动规)Max Sum Plus Plus

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1024题意过程:(转自https://blog.csdn.net/pmt123456/article/details/52695470 感谢)把一个数组分成m段,  sum(i1, j1) + sum(i2, j2) + sum(i3, j3) + ... + sum(im, jm),求使得上述...

2018-08-15 11:26:44 138

原创 HDU-1023(卡特兰数+大数的处理)Train Problem II

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1023题意:出栈的个数,递推式:h(n)=h(n-1)*(4*n-2)/(n+1);代码如下:#include<cstdio>#include<iostream>using namespace std;int a[110][110];//存放卡特兰数int ...

2018-08-15 10:55:02 137

原创 HDU-1022Train Problem I(栈的简单应用)

题目信息:http://acm.hdu.edu.cn/showproblem.php?pid=1022代码:#include<iostream>#include<cstdio>#include<stack>#include<cstring>#include<algorithm>using namespace std;...

2018-08-13 20:25:00 107

原创 HDU-1018(水题)

题目信息:http://acm.hdu.edu.cn/showproblem.php?pid=1018题意:求n阶乘的位数求n的位数公式:(int)log10(n)+1;求n阶乘位数就是每个里面相加;代码如下:#include<cstdio>#include<cmath>#include<iostream>using namespac...

2018-08-13 11:13:00 282

原创 HDU-1015(dfs)Safecracker

题目信息:http://acm.hdu.edu.cn/showproblem.php?pid=1015代码如下:#include<cstdio>#include<iostream>#include<cmath>#include<cstring>#define N 10005#include<algorithm>usi...

2018-08-12 21:09:18 122

原创 HDU-1006Tick and Tick

题意:就是找钟表的三个指针两两之间的角度超过n的概率。 解题思路:将一天的时间24小时只求12小时即可,因为后12小时和前12小时每种情况出现的概率一样,找出三个指针的相对角度:hm、hs、ms。以及时间t_hm、t_hs、t_ms。我们可以求出从重合到分离n度所需的时间n/hm,n/hs,n/ms,以及到再重合前n度所需的时间(360-n)/hm,(360-n)/hs,(360-n)/m...

2018-08-11 10:57:58 168

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除