上一页 1 2 3 4 5 6 ··· 12 下一页
摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4708首先来学习一个ac的代码:作者http://blog.csdn.net/xingyeyongheng#include #include #include #include #include #include #include #include #define INF 99999999 using namespace std; const int MAX=10; int s[MAX][MAX]; int main(){ int n; while(scanf("%d",& 阅读全文
posted @ 2013-09-20 00:13 814jingqi 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4715首先打素数表,然后分三类 x=0,>0, #include #include using namespace std; #define N 10000000 bool p[N+1]; void pre() { int d=sqrt(N); for(int i=2;i>n; for(int i=0;i0) { for(start=2;start<=10000000-x;start++) { ... 阅读全文
posted @ 2013-09-19 16:45 814jingqi 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4627[a,b]=ab/(a,b) a,b和一定时,越接近乘积越大,在接近的同时,尽量保持公因子最少。 如果n为2*k+1 那么 取a=2k,b=2k+1 最佳。 如果n为偶数=2k,就要进一步分k的奇偶性了。 n=4k 时 显然2k+2k会很小 2k-1,2k+1 就满足了 (2k-1,2k+1)=(2,2k+1)=1 。 如果n=4k+2 ,逐一实验2k+1,2k+1。 2k 2k+2. 2k-1,2k+3 。发现2k-1,2k+3是最佳的,而且他们已经互素了,再增大差距结果不会优于这组。 .. 阅读全文
posted @ 2013-09-19 15:00 814jingqi 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4707题目给出一颗树,要求求出深度大于D的结点的个数。有两种方法,改写dfs,给一个参数放层数(额,其实这里不需要转化为有根树,多于了)代码:#include #include #include #include using namespace std; #define maxn 100005 vector G[maxn]; int p[maxn]; int lev[maxn]; //vector leaf; void dfs(int u,int fa,int level) // 无根树... 阅读全文
posted @ 2013-09-18 00:17 814jingqi 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3789首先 题目要求只对m个国家排序,然后输出的顺序是给的国家编号的顺序~~!! 不一定是升序` wa了n次在这里然后用sort死做代码:#include #include #include #include using namespace std; struct nation { long double gold; long double all; long double area; int id; int rate1; int rate... 阅读全文
posted @ 2013-09-17 14:56 814jingqi 阅读(371) 评论(0) 推荐(0) 编辑
摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4706用一个三维数组来存贮要表示的矩阵,先画几个特例找规律,记住这个N是倒的...代码:#include #include using namespace std; char p[11][11][11]; int main() { for(int i=1;i #include #include using namespace std; int a[100][100]; bool vis[100][100]; void init() { memset(vis,0,size... 阅读全文
posted @ 2013-09-16 23:37 814jingqi 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4741题目大意 给你4个点 确定两条异面直线,求他们之间的距离和公垂线段的垂足。这里从twj1993那学的用直线参数方程+偏导数的方法,甚至可以解决n维坐标下的问题。设第一条直线的参数方程是x=x1+(x3-x1)*t1 , y=...,z=..... 第二条直线的参数方程同理可设(t2为参数)。然后两点之间的距离就可以表示为t1,t2的二元函数,令偏导为0就可以了。为了方便起见,变量用x,y代替。然后求函数系数的时候发现x,y是对称的,只需要把x改成y,z加上去就可以了最后,很关键的一点,dou. 阅读全文
posted @ 2013-09-16 22:13 814jingqi 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4737或运算 a|b>=a, a|b>=b 而且还可能 a|b > max(a,b);所以枚举a[i] 开头的字符串时 一旦出现大于m 就可以break理论上是o(n*n) 加上一些优化 。 优化成什么样要看数据了 如果数据***钻 100000 个 0 ,m=1 那肯定会超时,不过还好数据不***钻 就这样水过去了不过还是收获一点心得--敢于写暴力啊代码:#include #include #include #include using namespace std; int a[1000 阅读全文
posted @ 2013-09-14 19:32 814jingqi 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 题目地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1677首先要求最大生成树,来保证图的连通性(基于贪心的思想--尽量炸代价小的路,能炸得更多) 然后在资金足够的情况下,一一去炸代价小的路,直到钱不够当前最便宜的路了,break掉代码:#include #include #include #include #include using namespace std; int p[50005]; struct edge { int id; int x; int y; int w; }... 阅读全文
posted @ 2013-09-13 00:09 814jingqi 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1230第i位表示的实际大小是前i 个素数的乘积那么多,(第0位表示1) 进位规则是这一位减去p[i] (例如第0位减去p[0]==2) 高以为加1 ,由于更加难进位了,所以加法先相加,然后一次进位扫描就能保证每一位在范围内。 输入输出有点麻烦,是这个题的考点吧代码:#include #include #include #include #include using namespace std; int p[101]; vector prime; int na[25]; int nb[25];... 阅读全文
posted @ 2013-09-12 20:48 814jingqi 阅读(97) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 12 下一页