- 博客(46)
- 资源 (3)
- 收藏
- 关注
原创 hdu 1075 What Are You Talking About
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1075。。字典树。。带着模版打了一个小时。。悲剧。。各种细节不注意。。以后还是少用sscanf()。。毕竟它的用法记得不太全面。下面是用数组模拟的字典树AC代码:#includeusing namespace std;struct node{ char eng
2011-11-30 17:00:14 543
原创 hdu 1059 Dividing
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1059多重背包。。不加a[i]=a[i]%10;会超时。。当a[i]大于10,造成的效果和10以下一样。下面是AC代码:#includeusing namespace std;int f[200009];int main(){ int a[7]; int sum;
2011-11-30 13:32:31 612 1
原创 hdu 1060 Leftmost Digit
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1060思路很简单。就是二分求解。每次只去第一个数。wrong 了很多次。很多细节没注意对于log10()要把里面的数强制转化成double 或者float.还有要把n要用__int64的。。开始觉得int型足够了。。但是好像 大于1亿的时候,在做乘的时候会超过int的范围。#incl
2011-11-30 11:30:04 641
原创 hdu 1200 To and Fro
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1200水题。。对于这种题目能迅速读懂题意才是王道。。。但是就是英语太烂了啊。。。然后直接模拟。下面AC代码:#include#includeusing namespace std;int main(){ int n; int i,j,len,flag; char
2011-11-30 10:20:38 697
原创 hdu 1878 欧拉回路
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1878如题判断无向图的回路。。一般有并查集判断。。和深搜和广搜。。。用深搜判断 主要判断每个点的入度和初度之和要是偶数。。不然肯定是不行的。。。然后深度搜索看是否一次访问了所有的点。。如果访问了全部点而且每个点的初度与入度之和为偶数就是回路了, ,这题用CIN输入。。。会超时
2011-11-29 22:59:30 1615
原创 hdu 1879 继续畅通工程
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1879还是最小生成树。。。一开始没想到。。瞎改模版。。然后细想才发现。。如果已经修的路就把这两点的权值改成0就 OK了。。下面是AC代码:#includeusing namespace std;#define N 9999999int map[101][101]
2011-11-29 18:49:19 638
原创 hdu 1875 畅通工程再续
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1875又是最小生成树。。一开始错了几次。。。我以为是当两段路大于1000或者小于10就会不符合要求。。其实是读错题意了。。当两段路大于1000或者小于10。。只应该把这段路变成死路。下面是AC代码:#include#includeusing namespace std
2011-11-29 18:20:46 459
原创 hdu 1863 畅通工程
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1863又是最小生成树。。。照的上题的模版稍微改动了一下。。下面是AC代码:#includeusing namespace std;#define N 9999999int map[101][101];int mark[101];bool visited[101];in
2011-11-29 14:07:10 547
原创 hdu 1233 还是畅通工程
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1233一看就知道是裸的最小生成树。。。下面我是用prim算法实现的。。prim算法的主要思想第一步任意找一个点。。当作起始点。。 。这时把他们看成 两个集合 q1={1} ,q2={2,3,4,......};然后在q2集合里的点中找到通往q1集合 最小的距离
2011-11-29 13:34:39 492
原创 hdu 1285 确定比赛名次
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1285一开始模拟做的,但是不知道错哪了。。后面 看题解才知道要用拓扑排序。。对于拓扑排序主要分成两步:第一步:选择一个入度为0的顶点并输入它;第二步:从网中删去该节点,并且删去从该顶点发出的全部有向边。重复一二。直到网中所有点已输出。下面是AC代码://拓扑排
2011-11-29 12:33:46 625
原创 hdu 1874 畅通工程续
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1874就是裸的单源最短路。。做的时候还是遇到了一些错误。。比如题目上说的,、、每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。应该在输入的时候就要更新a-b的最短距离。还有一开始开了个N=0x7fffffff ...这种题肯定是不行的。。
2011-11-28 19:39:05 521
原创 hdu 1873 看病要排队
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1873这题可以直接数组模拟 也可以用 优先队列。。不会优先队列 所以 整理学习一下。。首先要知道:标准库默认使用元素类型的‘然后常用的调用方法和调用队列类似。。在前面加上priority 就行, //priority_queueint> qi;自定义运算优
2011-11-27 21:52:34 931
原创 hdu 1872 稳定排序
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1872还是排序。。只要先排序在 标记 两次就可以了。。当成绩不同时 那个排序是错的。当只是姓名不相同时, 那个排序是不稳定的下面是AC代码:#include#include#includeusing namespace std;struct temp{ cha
2011-11-27 20:54:51 1409
原创 hdu 1871 无题
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1871水题。。排序处理即可下面是AC代码:#include#include#includeusing namespace std;struct ss{ int num; int ren; int money;}s[1001];int c;int cmp(
2011-11-27 20:42:06 874
原创 hdu 1081 to the max
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1081这题一看就是DF。。暴力肯定会超时的。 。但是在思考的时候没有想到怎么做、、、同时思考的方向也错了。。。其实DF类的难点也就是难以写出动态转移方程。。这题的主要是思想是将第i行的前j个元素存放在一起。。。。然后计算就方便多了。计算某个矩阵内的数就只要计算两列纵坐标之间的元素就可
2011-11-27 18:38:51 1144
原创 hdu 1276 士兵队列训练问题
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1276简单的模拟。。按他的要求做就是了。 。但是一开始没考虑到n下面是AC代码:#includeusing namespace std;int f[5009];int main(){ int t; int n,i; while(cin>>t) {
2011-11-27 14:52:19 2756
原创 hdu 1248 寒冰王座
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1248 简单背包问题。。用f[n]装载n元钱可以购买的最大钱数,那么ans=n-f[n];因为每个道具的数目是无限的。。所以从小到大循环。如果道具只有一个 从大到小循环。 下面是AC代码://2011/1127/11:47#includeusing namespace std
2011-11-27 11:54:49 1128
原创 hdu 1071 The Area
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1071 抛物线表达式为y= a(x-x1)^2+y1;直线表达式为y=kx+b;面积可通过积分来计算a(x-x1)^2+y1 -(kx+b)下面是AC代码:#include#includedouble x,y,x2,y2,x3,y3;double
2011-11-27 11:34:47 656
原创 hdu 1225 Football Score
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1225 就是对各种结构体排序。。在调用sscanf()函数时应该注意。。。应该加去地址符。。。。如sscanf("12","%c%",&a,&b); 和scanf()函数类似 下面是AC代码: #include#includeusing namespace std;char
2011-11-26 22:18:46 924
原创 hdu 1222 Wolf and Rabbit
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1222 水题。根据题目模拟#includeusing namespace std;int main(){ int t; int m,n; cin>>t; while(t--) { cin>>m>>n; if(m==1|
2011-11-26 17:22:26 436
原创 hdu 1220 Cube
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1220 找规律题。。。关键是求出4个相同顶点的个数,首先容易推出 所有顶点数s(n)=(n-1) + (n-2) ....+1 = > (n-1)*n/2 其中的n为 单位正的个数。第二部求4个相同顶点 的个数可以分成两部分求出。。。第一部分求出n个部分上下之间的4
2011-11-26 17:02:53 1049
原创 hdu 1219 AC Me
。。。水题。。 下面是AC代码:#include #includeusing namespace std;int main(){ int i,x,j; char q[100001]; while(gets(q)) { int a[26]={0}; x=strlen(q); for(i=0;i<x;i++) if(q[i]>='
2011-11-26 10:46:30 1148
原创 hdu 1211 RSA
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1211 我表示题目虽然很水。但是我wrong了好几次。。。。尤其是题目都读了半天才明白题意。。英文太水了。。错在写x^e次方的函数。。这题就是 要你找出一个ASCII 的值x使得 : x^e%n==num(当前输入的数,e条件已给出)因为ASCII的范围比较小 果断暴力求解。
2011-11-26 10:39:31 877
原创 hdu 1214 圆桌会议
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1214 一开始老是读得不太清楚题意,所以不知道从何入手。 首先这题要思考,对于n个 数在直线上时,需要多少次才能将n个数逆序。例如 将 1234 -> 4321 。可以一步步递推。。。 比如将4提到首位需要3次。3提到首位需要2次。2提到首位需要1次。所以记直线上n个数逆序所需要的
2011-11-26 09:16:14 870
原创 hdu 1212 Big Number
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1212 因为b不大。。可以直接模拟。不用进行大数计算。 下面是AC代码:#includeusing namespace std;int main(){ char a[1009]; int b; int len; while(cin>>a>>b) {
2011-11-25 22:45:11 616
原创 hdu 1213 How Many Tables
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1213 简单的并查集的应用。。 #includeusing namespace std;int f[1009];int tt[1009];int find(int a){ if(a!=f[a]) f[a]=find(f[a]); return f[a];
2011-11-25 22:03:09 492
原创 hdu 2110 Eddy's 洗牌问题
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1210 暴力法。。超时了。。。#includeusing namespace std;int f[100009];int main(){ int n; int t=1; int ans; for(n=1;n<=100001;n++) { ans=0; t=1; wh
2011-11-25 20:25:47 858
原创 hdu 1862 EXCEL排序
题目: http://acm.hdu.edu.cn/showproblem.php?pid=1862 就是个排序。。代码比较难打。。还是打少了,题目没看仔细。。wrong了两次。 下面是AC代码:#includeusing namespace std;struct node{ char num[10],name[10]; int score;}st[
2011-11-25 15:54:10 712
原创 hdu 1861 游船出租
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1861 纯粹的模拟题。。。 #include#includeusing namespace std;int f[105];int mark[105];int change(char *s){ int hour=0,minute=0,i,len; len=strlen(s);
2011-11-25 15:21:19 672
原创 hdu 2176 取(m堆)石子游戏
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2176博弈类题目,SG函数的应用(SG函数资料 http://hi.baidu.com/%BA%A3%CF%E0%C1%AC/blog/item/ac7a41133db9b84af819b8a8.html) 然后对于第二部分的解法,首先暴力肯定是通不过的。。。我运用的应该是动态规划。
2011-11-25 11:01:22 856
原创 hdu 2117 Just a Numble
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2117 我是纯粹暴力法过的。。。这题应该可以进行优化。比如如果是有限循环的,找到循环周期然后对m取余就可以了。 下面是AC代码:#includeusing namespace std;int f[100001];int main(){ int n,m; int t,l; w
2011-11-24 16:54:11 855
原创 hdu 2116 Has the sum exceeded
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2116 编译器为G++会错。。一定要C++; 下面是AC代码#includeusing namespace std;int main(){ int K; while(cin>>K) { __int64 a,b,max=1; scanf("%I64d%I64d",
2011-11-24 11:57:11 863 1
原创 hdu 2115 I Love This Game
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2115 就是字符串处理排序。。 下面是AC代码: #include#includeusing namespace std;struct node{ char name[20]; char time[20]; int s;} f[20];int
2011-11-24 11:21:14 949
原创 hdu 2114 Calculate S(n)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2114 主要是计算前n项和的公式。前n项和的立方公式为 : s(n)=(n*(n+1)/2)^2; 前n项和的平方公式为:s(n)=n*(n+1)(2*n+1)/6; 转自百度搜索:公式证明 迭代法: 我们知道: 0次方和的求和公式ΣN^0=N
2011-11-24 10:47:08 1628
原创 hdu 1237 简单计算器
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1237 就是对栈 的应用。。但是在处理细节方面老是出错。 主要有两个错误。在判断栈顶元素和是否加入该栈的元素比较应该用一个while()循环做,而不能用if(),因为if只能判断当前的栈顶,第二个错误就是要对循环里面的元素进行判空处理,否则会越界!!!。 下面是AC代码。有点乱
2011-11-24 08:18:55 1361
原创 hdu 2601 An easy problem
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2601//本题考察的是整数的因子的个数, i * j + i + j =n,即为(i+1)*(j+1)=n+1,转化为了求解n+1的因子的个数//int temp=sqrt(n);这一句放在for循环里面就会超时,真郁闷。 #include#includeusing namespace
2011-11-18 17:08:51 779
原创 hdu 1671 Phone List
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1671 其实这题可以直接排序过的。。。一开始没有想到,因为在做trie树的专题,导致了思维定式。。让后用trie树做也出现了很多错误、没有释放内存,算法方面也没有考虑到位。导致错了很多次。还有在对照打模版时。。。居然直接打成:cur=str[i]-'a', 应该是cur = str[i]
2011-11-18 08:56:08 456
原创 trie树
字典树的两种实现方法: 数组实现的主要代码:struct node{ int num; bool f; int next[26]; void init(){num=0;f=0;memset(next,-1,sizeof(next));};}trie[1000000];int p;char input[100];void root(){
2011-11-16 22:11:30 480
原创 hdu 2102 A计划
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2102 WRONG了好多次。。就是对于传送点判断错误,思考不到位 。可以初始化地图 如果一个是传送点一个是墙或者两个都是传送点 都把他们变成墙,因为这些情况下传送点等于不可以进入。下面是AC代码:#include#include#includeusing namespace
2011-11-11 12:05:44 1433 2
原创 hdu 2082 找单词
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2082类似题目:选课时间(题目已修改,注意读题)http://acm.hdu.edu.cn/showproblem.php?pid=2079 开始以为是个多维背包。。但是做着做着老是得不出答案。。然后慢慢慢慢发现了。。 用ff【i】存储 上当前第i个字母与i前面哪些字母
2011-11-10 19:21:51 808
android studio 中文包
2016-11-25
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人