上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 30 下一页
  2012年10月15日
摘要: 大意:鞋匠接收了许多订单,有些鞋子有一定的修理期限,超过了这个期限就会罚款,让你求出最少赔款的方案,如果有多个相同的,请按输入的顺序从小到大输出。思路:可以证明是简单的贪心,即时间越早,而罚款数越大则越先修。按照fine/cost排序即可。CODE:#include<iostream>#include<cstdlib>#include<cstring>#include<cstdio>#include<cmath>#include<algorithm>usingnamespacestd;#defineMAXN1001stru 阅读全文
posted @ 2012-10-15 18:06 有间博客 阅读(415) 评论(0) 推荐(0) 编辑
摘要: 题意:给出一串那样的数字,很有规律的,总共有2147483647位,然后问你第 n 位上的数字是多少。思路:具体做法是用两个数组保存上面的数据。1、[] 数组表示前面所有段的位数,a[i]表示前i段一共有多少位。2、保存那一段具体的位数,b[]数组存储的是序列12345678910111213…各位位数对应数组的值,即b[1]=1, b[2]=2, b[3]=3, b[4]=4, b[5]=5, b[6]=6, b[7]=7, b[8]=8, b[9]=9, b[10]=1,b[11]=0, b[12]=1,b[13]=1, b[14]=1,b[15]=1, b[16]=1,b[17]=2, 阅读全文
posted @ 2012-10-15 17:26 有间博客 阅读(317) 评论(0) 推荐(0) 编辑
摘要: 大意:判断最多有多少点在同一直线上。思路:可以通过枚举所有点加判断三点共线去解决,即(y2-x1) /(x2-x1) = (y3-y1)/(x3-x1);注意输入格式比较特别。CODE:#include<iostream>#include<cstdlib>#include<cstring>#include<cstdio>#include<algorithm>#include<cmath>#include<map>usingnamespacestd;#defineMAXN10001intx[MAXN],y[MAX 阅读全文
posted @ 2012-10-15 15:35 有间博客 阅读(265) 评论(0) 推荐(0) 编辑
  2012年10月14日
摘要: CODE:#include<iostream>#include<cstdlib>#include<cstring>#include<cstdio>#include<algorithm>#include<cmath>#include<map>usingnamespacestd;#defineMAXN10000001map<string,int>Map;charsz1[MAXN],sz2[MAXN];voidKMP(intlen1,intlen2){inti=0,j=0;while(i<len1) 阅读全文
posted @ 2012-10-14 18:54 有间博客 阅读(94) 评论(0) 推荐(0) 编辑
摘要: CODE:#include<iostream>#include<cstdlib>#include<cstring>#include<cstdio>#include<algorithm>#include<cmath>usingnamespacestd;#defineMAXN1000001#defineINF0x3f3f3f3finta[MAXN],sum[MAXN*10];intn,m,tot;voidinit(){tot=0;memset(sum,0,sizeof(sum));memset(a,0,sizeof(a));} 阅读全文
posted @ 2012-10-14 18:53 有间博客 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 大意:给你一方程,让你求零点。思路:对函数求导,知道它是单调递减的。由于保留4位小数,可以通过二分枚举大于1e-9的方法求零点而不会无限循环。CODE:#include<iostream>#include<cstdlib>#include<cstring>#include<cstdio>#include<algorithm>#include<cmath>usingnamespacestd;#defineeps1e-9doublep,q,r,s,t,u;doublef(doublex){returnp*exp(-x)+q*s 阅读全文
posted @ 2012-10-14 18:52 有间博客 阅读(276) 评论(0) 推荐(0) 编辑
摘要: CODE:#include<iostream>#include<cstdlib>#include<cstring>#include<cstdio>#include<algorithm>usingnamespacestd;#defineMAXN500001intmain(){intn;while(scanf("%d",&n)&&n){for(inti=0;i<n;i++){scanf("%d%d",&a[i],&b[i]);}sort(a,a+n),s 阅读全文
posted @ 2012-10-14 18:50 有间博客 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 技巧挺强的。CODE:#include<iostream>#include<cstdlib>#include<cstring>#include<cstdio>#include<algorithm>usingnamespacestd;#defineMAXN51intcmp(stringa,stringb){if(a+b>b+a)return1;return0;}//string已经重载了<>=运算符stringstr[MAXN];intmain(){intn;while(scanf("%d",&am 阅读全文
posted @ 2012-10-14 18:49 有间博客 阅读(116) 评论(0) 推荐(0) 编辑
  2012年10月13日
摘要: CODE:#include<iostream>#include<cstdlib>#include<cstring>#include<cstdio>usingnamespacestd;charstr[10]="HDU";intmain(){intn;intT;scanf("%d",&T);while(T--){scanf("%d",&n);for(inti=0;i<3*n;i++){for(intj=0;j<n;j++){printf("%s" 阅读全文
posted @ 2012-10-13 22:13 有间博客 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 大意:给你一些定点,让你以代价最小的边将所有的点连起来。思路:数据范围很小,可以通过最小生成树或者回溯来解决。最小生成树去写时不知道哪错了,于是用回溯模拟了一遍,相当于模拟一个数组的全排列。AC CODE:#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<climits>//INT_MAX,整形范围内的最大整数。#include<algorithm>usingnamespacestd;#defineINF0x3f3f3f3fc 阅读全文
posted @ 2012-10-13 18:41 有间博客 阅读(551) 评论(1) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 30 下一页