上一页 1 2 3 4 5 6 7 ··· 10 下一页
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2525WA了很多次,从网上档的代码,留着自己慢慢悟View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 5 6 int N, D, A, K, X; 7 // 保留两个信息,即当天克隆人已经生存的天数 8 // 以及正在培育中的人已经培育的天数 9 // 由于天数最多只有100天,所以我们可以使用数组来进行模拟 10 11 __int64 P[105], W[105]; // P表 阅读全文
posted @ 2013-05-05 10:11 zlyblog 阅读(202) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2522View Code 1 #include<stdio.h> 2 #include<string.h> 3 int mark[100002]; 4 void pow(int x) 5 { 6 int t; 7 mark[1]=1; 8 t=1; 9 while(t)10 {11 t=t*10;12 printf("%d",t/x);13 t=t%x;14 if(mark[t])//再次出现相同的余数,... 阅读全文
posted @ 2013-05-04 19:19 zlyblog 阅读(182) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2491View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define N 100008 4 struct cere 5 { 6 int x,y; 7 int mid,end; 8 }a[N]; 9 int cmp(const void *a,const void *b)10 {11 struct cere *c,*d;12 c=(struct cere *)a;13 d=(struct cere *)b;14 ... 阅读全文
posted @ 2013-05-04 11:22 zlyblog 阅读(164) 评论(0) 推荐(0)
摘要: View Code 1 #include<stdio.h> 2 #include<math.h> 3 #include<string.h> 4 #define M 999999999 5 #define N 2000000 6 int a[610],map[610][610]; 7 int b[610],c[610],g[N]; 8 int Min(int x,int y) 9 { 10 if(x>y) 11 return y; 12 else 13 return x; 14 } 15 void prim() 16 { 17 ... 阅读全文
posted @ 2013-05-03 17:59 zlyblog 阅读(174) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=1094思路: 题目的意思就是说每输入一个关系,进行一次拓扑排序,知道能够确定n个字母的顺序 或者是存在环。在编写程序时首先要判断是不是有环,如果有,返回0, 如果存在多种情况,标记flag2为-1,然后继续进行判断有没有环,如果没有,返回-1; 如果没没出现上述情况,则返回1。View Code 1 #include <stdio.h> 2 #include <string.h> 3 int n,m,j,i; 4 int map[100][100],q,d[100],t[100]; 5 int flag,flag1; 阅读全文
posted @ 2013-05-02 11:17 zlyblog 阅读(167) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1865简单递推+大数。 ans[n]=ans[n-1]+ans[n-2]。 由于数字只有'1'和'2'这两种,那么当让第n位为1的时候,ans[n]加上ans[n-1];当让最后两位合并成2的时候,ans[n]加上ans[n-2](因为要保证倒数第二位一定是1)。 算出来的ans就是一个斐波那契数列。View Code 1 #include"stdio.h" 2 #include"string.h" 3 #include"std 阅读全文
posted @ 2013-04-30 10:16 zlyblog 阅读(305) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2955题意:Roy想要抢劫银行,每家银行多有一定的金额和被抓到的概率,知道Roy被抓的最大概率P,求Roy在被抓的情况下,抢劫最多。分析:被抓概率可以转换成安全概率,Roy的安全概率大于1-P时都是安全的。抢劫的金额为0时,肯定是安全的,所以d[0]=1;其他金额初始为最危险的所以概率全为0;注意:不要误以为精度只有两位。View Code 1 #include<stdio.h> 2 #include<string.h> 3 double MAX(double x,double y) 阅读全文
posted @ 2013-04-27 11:12 zlyblog 阅读(197) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1009View Code 1 #include<stdio.h> 2 #include<algorithm> 3 using namespace std; 4 5 struct Trade 6 { 7 int j,f; 8 double percent; 9 }mouse[3001];10 bool cmp(Trade a,Trade b)11 {12 return a.percent>b.percent;13 }14 int main()15 {16 int m,n,i;... 阅读全文
posted @ 2013-04-26 16:41 zlyblog 阅读(154) 评论(0) 推荐(0)
摘要: Problem Description有N个比赛队(1<=N<=500),编号依次为1,2,3,。。。。,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩,只知道每场比赛的结果,即P1赢P2,用P1,P2表示,排名时P1在P2之前。现在请你编程序确定排名。Input输入有若干组,每组中的第一行为二个数N(1<=N<=500),M;其中N表示队伍的个数,M表示接着有M行的输入数据。接下来的M行数据中,每行也有两个整数P1,P2表示即P1队赢了P2队。Output给出一个符合要求的排名。输出时队伍号之间有空格, 阅读全文
posted @ 2013-04-26 10:49 zlyblog 阅读(606) 评论(0) 推荐(0)
摘要: #include <algorithm>using namespace std;1.默认的sort函数是按升序排。对应于1)sort(a,a+n); //两个参数分别为待排序数组的首地址和尾地址2.可以自己写一个cmp函数,按特定意图进行排序。对应于2)例如:int cmp( const int &a, const int &b ){ if( a > b ) return 1; else return 0;}sort(a,a+n,cmp);是对数组a降序排序又如:int cmp( const POINT &a, const POINT &b ) 阅读全文
posted @ 2013-04-26 08:17 zlyblog 阅读(185) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 ··· 10 下一页