- 博客(47)
- 收藏
- 关注
原创 HDOJ 2602 Bone Collector--01背包
题目来源:HPU 2602--Bone CollectorProblem DescriptionManyyears ago , in Teddy’s hometown there was a man who was called “BoneCollector”. This man like to collect varies of bones , such as dog’s , cow’s
2015-08-27 10:15:48
791
原创 POJ 2264 Advanced Fruits--最长公共子序列
题目来源:POJ2264Advanced FruitsDescriptionThecompany "21st Century Fruits" has specialized in creating new sortsof fruits by transferring genes from one fruit into the genome of another one.Most tim
2015-08-27 09:22:32
1276
原创 HDOJ 1869 六度分离
http://acm.hdu.edu.cn/showproblem.php?pid=1869Problem Description1967年,美国著名的社会学家斯坦利·米尔格兰姆提出了一个名为“小世界现象(small worldphenomenon)”的著名假说,大意是说,任何2个素不相识的人中间最多只隔着6个人,即只用6个人就可以将他们联系在一起,因此他的理论也被称为“六度分离”
2015-08-26 17:52:22
775
原创 HDOJ 1869 六度分离
Dijkstra算法本题中每个节点到其他节点的最短路径长度都要判断即要以每个节点为源点进行判断。并且可以证明只以一个节点为源点进行判断有特殊数据无法处理 #include#include#includeusing namespace std;#define MAX 0x3f3f3f3f#define N 105int map[N][N];//存放a,b之间的关系,及
2015-07-30 15:52:51
390
原创 百练 2703 骑车与走路 动态数组malloc
http://bailian.openjudge.cn/practice/2703#include#include int main(){int n;int i; scanf("%d",&n);double *juli=(double *)malloc(n*sizeof(double));for(i=0;i{scanf("%lf",&juli[i
2015-07-22 19:19:56
466
原创 ZOJ 1241 Geometry Made Simple
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1241#include#include#include#includeint main(){double a,b,c;double s;int i=0;while(scanf("%lf%lf%lf",&a,&b,&c),(a||
2015-07-22 19:16:37
423
原创 HDOJ 2017 字符串统计
http://acm.hdu.edu.cn/showproblem.php?pid=2017#include#include#include#includechar a[110];int main(){int i;int str; while(gets(a)) { str=strlen(a); if(isalpha(a
2015-07-22 19:13:39
380
原创 HDOJ 2502 月之数
http://acm.hdu.edu.cn/showproblem.php?pid=2502#include#include#include#includeusing namespace std;int main(){int T;int n;int i;int s;//每个数的二进制个数 int a[25];for(i=1;i{s=pow
2015-07-22 19:12:06
464
原创 HDOJ 2014 青年歌手大奖赛_评委会打分
http://acm.hdu.edu.cn/showproblem.php?pid=2014#include#include#include#include#includeint cmp(const void *a,const void *b){return *(double *)a-*(double *)b;}int main(){int i;
2015-07-22 19:10:57
517
原创 HDOJ 1862 EXCEL排序
http://acm.hdu.edu.cn/showproblem.php?pid=1862#include#include#include#includeusing namespace std;#define N 100010struct excel{char xh[10];char name[10];int grade;}a[N];int
2015-07-22 19:08:35
384
原创 HDOJ 2087 剪花布条----strstr函数
http://acm.hdu.edu.cn/showproblem.php?pid=2087/*strstr(str1,str2)是一种函数,从字符串str1中查找是否有符串str2,如果有,从str1中的str2位置起,返回str1的指针,如果没有,返回null。*/#include#include#include#include#include#de
2015-07-22 19:06:40
403
原创 HDOJ 2027 单词数
http://acm.hdu.edu.cn/showproblem.php?pid=2072#include#include#include#include#include#define N 10000 struct danci{char c[100];}a[N];char b[N];int main(){int i,j,k;int
2015-07-22 19:04:12
413
原创 HDOJ 2028 Lowest Common Multiple Plus (求n个数的最小公倍数)
http://acm.hdu.edu.cn/showproblem.php?pid=2028#include#include#include#includeint main(){ int n; int i; int a[100]; int tem; while(~scanf("%d",&n)) {
2015-07-22 19:01:17
385
原创 HDOJ 1234 开门人和关门人
http://acm.hdu.edu.cn/showproblem.php?pid=1234#include#include#include#includeusing namespace std;#define N 1000struct jilu{char name[N];char s[N],e[N];}a[N];int cmp1(jilu x,
2015-07-22 18:43:23
435
原创 HDOJ 1860 统计字符
http://acm.hdu.edu.cn/showproblem.php?pid=1860#include#include#include#include#includeint main(){int n1,n2;int i,j;char a[6];char b[81];int c[6];while(gets(a)){if(a[0]
2015-07-22 17:57:38
388
原创 HDOJ 2089 不要62
http://acm.hdu.edu.cn/showproblem.php?pid=2089#include#include#include#include#define N 1000000int a[N];int main(){int n,m;int i;int sum;void cmp(int i);for(i=1;i{cmp
2015-07-22 17:55:13
345
原创 HDOJ 1200 To and Fro
http://acm.hdu.edu.cn/showproblem.php?pid=1200#include#include#include#include#includechar a[205];char b[25][205];int main(){int n;int i,j,k;int str;while(scanf("%d",&n),n)
2015-07-22 17:51:49
325
原创 HDOJ 2035 人见人爱A^B-----二分快速求幂
http://acm.hdu.edu.cn/showproblem.php?pid=2035//二分快速求幂 #include#include#include#includeint main(){ int a,b; int s; while(scanf("%d%d",&a,&b),a+b) { int cmp(int a,int b); s=
2015-07-20 21:28:26
436
原创 HDOJ 2080 Lowest Common Multiple Plus
http://acm.hdu.edu.cn/showproblem.php?pid=2028#include#include#include#includeint main(){ int n; int i; int a[100]; int tem; while(~scanf("%d",&n)) { tem=0; for(i=1;i
2015-07-20 21:18:59
370
原创 矩阵乘法
#include#include#include#include#define N 100int a[N][N],b[N][N];//a,b矩阵int c[N][N];//a,b的乘积int main(){ int p,q,r,s;//a,b的行列 int i,j,k; scanf("%d%d",&p,&q); for(i=1;i fo
2015-07-20 15:54:13
287
原创 HDOJ 1050 Moving Tables 找重叠最多的点
http://acm.hdu.edu.cn/showproblem.php?pid=1050//找重叠最多的点 #include#include#includeusing namespace std;int main(){ int T; int n; int a,b; int i,j; int c[210]; cin>>T; while(T-
2015-07-20 15:39:02
320
原创 HDOJ 1097 A hard puzzle
//HDOJ 1097 A hard puzzle//二分快速求幂 #include#include#include#includeint main(){ int cmp(int a,int b); int a,b; int s; while(~scanf("%d%d",&a,&b)) { s=cmp(
2015-07-20 15:02:32
326
原创 NYOJ 112 指数运算
//快速幂//AC代码 #include#includeint main(){ int a,b; long long s;//__int64不能参与循环??? while(~scanf("%d%d",&a,&b)) { long long cmp(long long a,long long b); s=cmp(a,b); printf("%l
2015-07-20 15:00:13
314
原创 二分求幂
//二分求幂and二分快速求幂 #includeint main(){ int cmp(int a,int b); int a,b; int s; while(~scanf("%d%d",&a,&b)) { s=cmp(a,b); printf("%d\n",s); } return 0;} //普通求幂--同pow(a,b) /*
2015-07-19 21:54:28
379
原创 POJ 1979 Red and Black
http://poj.org/problem?id=1979//POJ 1979 Red and Black#include#include#define N 25int W,H;//列,行 int vis[N][N];//标记已走过的 char map[N][N];//储存矩形房间的瓷砖分布 int sum;//统计可行走黑色瓷砖数目 int main()
2015-07-19 21:22:56
323
原创 NYOJ 264--国王的魔镜
http://acm.nyist.net/JudgeOnline/problem.php?pid=264#include#includeint main(){ int N,n; int i,lap; char a[105]; scanf("%d",&N); getchar(); while(N--) { lap=0; gets(a+1);
2015-06-21 17:49:47
335
原创 NYOJ993--How many integers can you find
http://acm.nyist.net/JudgeOnline/problem.php?pid=993#include#include/*辗转相除法原理:两个整数的最大公约数等于其中较小的数和两数的相除余数的最大公约数。当余数为0时,较小数与余数0的最大公约数为其本身另:余数绝对小于较小数 */int gcd(int m1,int m2) { int
2015-06-21 17:12:32
430
原创 HDOJ 1272--小希的迷宫
http://acm.hdu.edu.cn/showproblem.php?pid=1272//小希的迷宫:判断图G是不是树/*树:如果图G是连通的且没有回路,则称之为树;图G的阶n>1时,以下说法等价:G是树; G是无回路的,且有n-1条边; G是连通的,且有n-1条边. 如果两个要合并的节点的根节点相同,说明有回路 如果根节点>=2,说明不连通*/
2015-06-21 15:58:41
440
原创 POJ 1659 Frogs' Neighborhood
http://poj.org/problem?id=1659Havel-Hakimi定理 .判断度序列是否可图---两种不可图的情况: (1).某次对剩下的序列排序后,最大的度序列d1超过了剩下的顶点数;(2).对最大度序列后的d1个数各减1后,出现了负数; .根据可图度序列构造出一个图并用邻接矩阵表示出来: (1).声明一个vertex结构体,确保顶点序号与输入时
2015-06-14 15:07:06
451
原创 HDOJ继续畅通工程
http://acm.hdu.edu.cn/showproblem.php?pid=1879#include#include#define MAX 0x3f3f3f#define N 110int graph[N][N],visited[N],ps[N],a[N][N];int cmp(int m){ int i,j; int min,pos,sum=0;
2015-06-07 09:45:28
328
原创 NYOJ筹建工程之并查集and最小生成树prim算法
http://acm.nyist.net/JudgeOnline/problem.php?pid=502//并查集and最小生成树prim算法 #include#include#define MAX 0x3f3f3f#define N 110int graph[N][N];int visited[N],ps[N];int a[N];int find(int k)
2015-06-07 09:22:05
328
原创 HDOJ畅通工程之并查集and最小生成树prim算法
http://acm.hdu.edu.cn/showproblem.php?pid=1863#include#include#define MAX 0x3f3f3f#define N 110int graph[N][N],visited[N],ps[N];int a[N];int find(int k) { int r=k; while(a[r]!=r)
2015-06-07 09:19:45
371
原创 HDOJ畅通工程之并查集
http://acm.hdu.edu.cn/showproblem.php?pid=1232#include#include#define N 1010int a[1010];int find(int t){ int r=t; while(a[r]!=r) //找父节点 { r=a[r]; } int x=t,tem; while(a[x]!
2015-06-06 15:33:04
334
原创 HDOJ还是畅通工程之--prim算法
http://acm.hdu.edu.cn/showproblem.php?pid=1233#include#include#define MAX 0x3f3f3fint graph[110][110];int visited[110],ps[110];int cmp(int n){ int i,j,pos,sum=0,min; memset(visited,0
2015-06-06 13:15:45
493
原创 NYOJ会场安排问题
http://acm.nyist.net/JudgeOnline/problem.php?pid=14&rec=sim#include#include#includeusing namespace std;#define N 10010struct jiemu{ int s,e;}a[N];int cmp(jiemu j,jiemu k) //按节目结束时间
2015-06-01 17:56:21
395
原创 HDOJ喷水装置(二)--区间完全覆盖问题
http://acm.nyist.net/JudgeOnline/problem.php?pid=12&rec=sim#include#include#include#includeusing namespace std;#define M 10010struct zb{ double a,b;}c[M];int cmp(zb p,zb q) //按左
2015-06-01 17:51:20
437
原创 NYOJ Radar 贪心之区间选点问题
http://acm.nyist.net/JudgeOnline/status.php?pid=287//贪的是:一个雷达能覆盖尽可能多的岛屿 #include#include#include #includeusing namespace std;#define N 1010struct zb{ double a,b;}c[N];int cmp(z
2015-05-30 15:28:07
467
原创 NYOJ计算球体积----四舍五入
/*#include#include#define PI 3.1415926int main(){ double r,s; while(~scanf("%lf",&r)) { s=4*PI*pow(r,3)/3; printf("%.0lf\n",s); //直接进行整数位的四舍五入 } return 0;}//运行正确 */
2015-05-30 14:45:14
618
原创 NYOJ喷水装置(一)
http://acm.nyist.net/JudgeOnline/problem.php?pid=6//贪心,贪最少的喷水装置,即贪最大的喷水半径#include#include#includeusing namespace std;double a[650];int cmp(double c,double d) //升序排列 { return c>d;}
2015-05-30 11:35:24
421
原创 HDOJ过河问题
http://acm.nyist.net/JudgeOnline/problem.php?pid=47//贪最短时间 #include#include#includeusing namespace std;#define N 1010int a[N];int cmp(int m) //递推 { if(m==1) return a[0]; if(m==
2015-05-30 11:29:35
341
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人