
基础
文章平均质量分 68
蚕豆儿
这个作者很懒,什么都没留下…
展开
-
七种qsort排序方法
七种qsort排序方法 一、对int类型数组排序 int num[100]; Sample: int cmp ( const void *a , const void *b ) { return *(int *)a - *(int *)b; } qsort(num,100,sizeof(num[0]),cmp); 二、对char类型转载 2013-05-28 19:44:43 · 880 阅读 · 0 评论 -
BNU Avoid The Lakes
http://www.bnuoj.com/bnuoj/problem_show.php?pid=3739搜索题,就是找到里面联通区域最大值AC代码:#include#include#includeusing namespace std;int n,m,k,now,ma,p;int a[110][110];int dir[4][2]={{0,1},{0原创 2013-08-12 09:33:57 · 729 阅读 · 0 评论 -
hdu 1022 Train Problem I
http://acm.hdu.edu.cn/showproblem.php?pid=1022模拟栈。搞了好久,好像是输出问题。。。AC代码:#include#include#include#includeusing namespace std;int nu[10000];int main(){ int n,i,k,p; char in[1000原创 2013-08-12 10:28:12 · 860 阅读 · 0 评论 -
Strange Addition
http://codeforces.com/problemset/problem/305/A这题就是意思没看懂,一开始以为只要个位数只要一个为0就能相加,没想到到CF里面提交第三组就过不了,才发现是要各个位上面都要有一个为0的时候才能相加。题意很重要。。。。AC代码:#include#include#includeusing namespace std;in原创 2013-08-12 15:32:04 · 988 阅读 · 0 评论 -
BNU Concentric Rings
http://www.bnuoj.com/bnuoj/problem_show.php?pid=16030Concentric RingsThere are several different concentric rings on the ground. Some of them may overlap. In Figure 1, there ar原创 2013-08-13 15:18:58 · 756 阅读 · 0 评论 -
Triangular numbers
http://codeforces.com/problemset/problem/47/ATriangular numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputst原创 2013-08-13 15:11:56 · 1486 阅读 · 0 评论 -
BNU Invading system
http://www.bnuoj.com/bnuoj/problem_show.php?pid=29364这个题被坑了。题意:密码就是那些数字里面的数,转换成二进制后1最少的那个数,当1的个数相同的时候,要选最小的那个数。AC代码:#include#include#includeusing namespace std;bool cmp(int a, int原创 2013-08-15 17:32:01 · 710 阅读 · 0 评论 -
hdu 1865 1sting
http://acm.hdu.edu.cn/showproblem.php?pid=1865这个的递推公式为a[i]=a[i-1]+a[i-2]。唯一要注意的就是后面数据存不下,要用数组来存大数。AC代码:#include#include#includeusing namespace std;int main(){ int t,n,i,j,原创 2013-08-17 19:22:06 · 1351 阅读 · 0 评论 -
BNU Questions and answers
http://www.bnuoj.com/bnuoj/problem_show.php?pid=2490这个题是先输入一个整数n,说明有几个数据,然后输入n个整数,然后用三个#分开,后面输入整数k,代表有k个数据,后面每个数据代表查询前面那几个整数中从小到大排序后的第几个数。AC代码:#include#include#includeusing namespace s原创 2013-08-18 19:40:29 · 1316 阅读 · 0 评论 -
BNU Box of Bricks
http://www.bnuoj.com/bnuoj/problem_show.php?pid=1596这个题一开始以为要求最少移动次数,把我吓到了,原来只要求最少移动几个方块就行了。。这一下就变简单很多了。。AC代码:#include#include#includeusing namespace std;bool cmp(int a, int b){原创 2013-08-18 19:50:44 · 1176 阅读 · 0 评论 -
Multiple of 17(湖南省第六届ACM竞赛题)含有java大数模板
Multiple of 17Time Limit:1000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit Status Practice UVA 11879DescriptionTheorem: If you drop the last digit d of an integ原创 2013-09-04 14:46:46 · 1145 阅读 · 0 评论 -
hdu 1166 敌兵布阵(线段树,树状数组)
http://acm.hdu.edu.cn/showproblem.php?pid=1166直接线段树模板AC代码:#include#include#includeusing namespace std;struct node{ int l; //左起点 int r; //右终点 int sum; //区间数据总和};node p原创 2013-09-03 13:44:12 · 928 阅读 · 0 评论 -
hdu 1002 A + B Problem II(大数模板)
http://acm.hdu.edu.cn/showproblem.php?pid=1002大数运算,用数组存数据,参考刘汝佳的《算法竞赛入门经典》里面写的,顺便套模板。还可以用这个模板来写减法、乘法。除法运算暂时不清楚如果有小数怎么处理。。。AC代码:#include#include#includeusing namespace std;#define原创 2013-08-31 09:40:46 · 851 阅读 · 0 评论 -
hdu 统计难题(字典树)
http://acm.hdu.edu.cn/showproblem.php?pid=1251字典树模板:代码:/************HDU 1251 统计难题字典树模板 **************/#include#define MAX 26typedef struct TrieNode{ int nCount; struct T转载 2013-08-21 19:36:16 · 698 阅读 · 0 评论 -
优先队列的用法
转载来源:http://www.cppblog.com/shyli/archive/2007/04/06/21366.html在优先队列中,优先级高的元素先出队列。标准库默认使用元素类型的优先队列的第一种用法,也是最常用的用法:priority_queueint> qi;通过故示例1中输出结果为:9 6 5 3 2第二种方法:在示例1中,如果我们要把转载 2013-09-18 14:47:09 · 610 阅读 · 0 评论 -
Dijkstra算法 用C++面向对象写
这个是我在coursera.org上学习 C++ For C Programmers 课程的一个作业。用C++面向对象来写算法,这增加了我对面向对象的理解。方法为:1、创建一个class类2、定义私有数据成员3、定义各种方法来对私有数据进行操作代码如下:#include #include #define maxx 999999 //dustance原创 2013-11-02 19:16:07 · 1048 阅读 · 0 评论 -
BNU Eugeny and Array
http://www.bnuoj.com/bnuoj/problem_show.php?pid=29452题意:给你一个只有1和-1组成的数组,然后给你一个范围,求重新排列后在这个范围内求和能否为0,能为0则输出为1,否则为0这个题只要计算一下范围是否为偶数,偶数个数相加才可能为0,然后统计一下1和-1的个数,看里面最少的个数是否大于等于范围的一半。AC代码原创 2013-08-12 08:25:36 · 862 阅读 · 0 评论 -
Beautiful Year
http://codeforces.com/problemset/problem/271/ABeautiful Yeartime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstand原创 2013-08-09 19:35:54 · 1168 阅读 · 0 评论 -
The World is a Theatre
http://codeforces.com/problemset/problem/131/CThe World is a Theatretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutpu原创 2013-08-09 19:41:24 · 910 阅读 · 0 评论 -
C++ STL
C++ STL 的用法上次遇到容器的运用,根本不会,然后学长和学弟(这个强人)到网上就找到了容器的用法和帮助文档,真是瞌睡来了就有人送枕头啊!!(PS:我找过C++的标准库文档,要么就是有问题打不开,要么就不是我要的。。哭。。。)数据结构描述实现头文件向量(vector)连续存储的元素原创 2013-06-29 20:10:28 · 1777 阅读 · 0 评论 -
以空格结束字符串输入
其实思路很简单,只是我一开始就想到的字符串输入就是直接用 gets,发现gets无法以空格结束输入,后面在网上看了几篇文章,发现直接用scanf来输入,由于scanf是遇到 空格 回车 和 tab键 结束输入,而gets只能遇到回车结束输入。因此用一下方法解决:char a[100],c;int i;i = 0;while(scanf("%c",&c) && c != ' '){a[原创 2013-05-28 19:41:49 · 9032 阅读 · 0 评论 -
HDU 1157 Who's in the Middle
http://acm.hdu.edu.cn/showproblem.php?pid=1157问题:求里面的中间值。很简单的题,排序后直接找2/n的那个值AC代码:#include#include#include#includeusing namespace std;int c[10010];int main(){ int n,i,mi原创 2013-07-29 11:29:24 · 806 阅读 · 0 评论 -
Stones on the Table
题目网址:http://codeforces.com/problemset/problem/266/AStones on the Tabletime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard原创 2013-08-05 20:00:06 · 1099 阅读 · 0 评论 -
hdu 1051 Wooden Sticks
http://acm.hdu.edu.cn/showproblem.php?pid=1051这个题直接用贪心做。题意就是一个机器重置一次要一分钟,只要长度和重量都比前一次小则不用重置机器,可以直接加工。求重置最少的次数。首先对它排序,然后一个一个找满足条件的,并标记这个已经被加工了,被加工的不需要在加工。AC代码:#include#include原创 2013-08-07 10:54:52 · 783 阅读 · 0 评论 -
Team
http://codeforces.com/problemset/problem/231/A Teamtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outpu原创 2013-08-08 08:38:36 · 633 阅读 · 0 评论 -
Theatre Square
http://codeforces.com/problemset/problem/1/ATheatre Squaretime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard原创 2013-08-08 08:34:19 · 1560 阅读 · 0 评论 -
POJ 1852 Ants
http://www.bnuoj.com/bnuoj/problem_show.php?pid=1971这个题一开始我想多了。。。其实这个题想通了就很简单,没想通就难了。。因为蚂蚁都是一样的。所以,最短时间就是离木棒最中间的那个蚂蚁向最近的边缘移动就是结果。最远的那个题目说两只蚂蚁相碰时反向移动,其实不用管它是否掉头,直接看成没有掉头就行了,所以这个结果即为在木棒最边缘原创 2013-08-17 19:18:25 · 1071 阅读 · 0 评论 -
Robot Instructions
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3947Robot InstructionsYou have a robot standing on the origin of x axis. The robot will be given some instructions. Your task is to predict its position aft原创 2013-08-08 08:46:39 · 1173 阅读 · 0 评论 -
Three Families
2012年湖南省省赛题http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3946Three FamiliesThree families share a garden. They usually clean the garden toge原创 2013-08-08 09:36:04 · 873 阅读 · 0 评论 -
HDU 2199 Can you solve this equation?
http://www.bnuoj.com/bnuoj/problem_show.php?pid=6343这个题直接用2分法。因为数据x范围已经限定在1到100,所以直接带入公式里面计算比较结果sum和y,如果sum>y则肯定x太大,不断缩小范围即可。这个判断sum和y相等的条件是只要两者相减差值小于一定值时即可判定为相等。AC代码:#include#inclu原创 2013-08-17 19:54:48 · 909 阅读 · 0 评论 -
hdu 4544 湫湫系列故事——消灭兔子
http://acm.hdu.edu.cn/showproblem.php?pid=4544这个题用优先队列做旧很简单了,但是我只会队列,但不会优先队列,还要努力学习C++里面的重载。。T_T。。思路就是对兔子的血量先进行排序,然后对剑的杀伤力排序,然后用优先队列,弹出能杀死兔子但是价格又是最低的那个箭。直接看代码把。。AC代码:#include#incl原创 2013-08-08 18:43:27 · 1000 阅读 · 0 评论 -
System of Equations
http://codeforces.com/problemset/problem/214/ASystem of Equationstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutput原创 2013-08-09 08:17:34 · 1019 阅读 · 0 评论 -
Dragons
http://codeforces.com/problemset/problem/230/ADragonstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard out原创 2013-08-09 08:14:39 · 1050 阅读 · 0 评论 -
I_love_%username%
http://codeforces.com/problemset/problem/155/AI_love_%username%time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputst原创 2013-08-09 19:38:33 · 1224 阅读 · 0 评论 -
数学分析题:约瑟夫环
约瑟夫环是一个数学的应用问题:已知n个人(以编号1,2,3...n分别表示)围坐在一张圆桌周围。从编号为k的人开始报数,数到m的那个人出列;他的下一个人又从1开始报数,数到m的那个人又出列;依此规律重复下去,直到圆桌周围的人全部出列。原创 2014-05-27 19:36:52 · 987 阅读 · 0 评论