上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 42 下一页
摘要: 题意:从n个男孩中挑出k个,每个人有两个属性u,v怎样挑选能得到最大的value定义状态:dp[ i ][ j ]:从前i个中挑出j个得到的最大value对于第i个,若选择,dp[i][j]=dp[i-1][j-1]+a[i].u-a[i].v*(j-1) 若不选择,dp[i][j]=dp[i-1][j]+0;View Code 1 #include<algorithm> 2 #include<stdlib.h> 3 #include<string.h> 4 #include<stdio.h> 5 using namespace std; 6 c 阅读全文
posted @ 2013-02-09 23:07 xxx0624 阅读(310) 评论(0) 推荐(0) 编辑
摘要: 推理一个数字含有一个5就能有一个0,但是在计数的时候要除去这个5,再去进行新的计算。View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<math.h> 4 typedef __int64 int64; 5 int main(){ 6 int t; 7 scanf("%d",&t); 8 while( t-- ){ 9 int64 n;10 scanf("%I64d",&n);11 int64 ans=0;12 int64 now=5 阅读全文
posted @ 2013-02-09 21:20 xxx0624 阅读(299) 评论(0) 推荐(0) 编辑
摘要: 题意:给定一个字典,给定一些询问,对于每个询问,在字典中找出与之匹配的单词(匹配的规则:两者的排序之后结果是相同的)View Code 1 #include<stdio.h> 2 #include<string> 3 #include<map> 4 #include<iostream> 5 #include<algorithm> 6 using namespace std; 7 map<string,string>mp; 8 string my_end="XXXXXX"; 9 int main(){10 阅读全文
posted @ 2013-02-07 12:03 xxx0624 阅读(311) 评论(0) 推荐(0) 编辑
摘要: 题意:求能否把一个矩形放入另一个矩形中。只有两种情况 见代码View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 #include<math.h> 5 #include<algorithm> 6 using namespace std; 7 const double pi=acos(-1.0); 8 int main(){ 9 int t;10 //printf("%lf\n",pi);11 scanf("%d& 阅读全文
posted @ 2013-02-07 11:52 xxx0624 阅读(270) 评论(0) 推荐(0) 编辑
摘要: 三角形重心:(x1+x2+x3)/3,(y1+y2+y3)/3 这是特殊情况,各点的质量相等多边形 x=( sigma )( xi*mi )/sumArea y=( sigma )( yi*mi )/sumArea先把多边形变成多个三角形,分别求出mi(有点像面缩点),然后得到新的点的坐标。。。View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 #include<math.h> 5 const int maxn = 1000005; 6 struct 阅读全文
posted @ 2013-02-06 21:13 xxx0624 阅读(360) 评论(0) 推荐(0) 编辑
摘要: 题意:一家店从早上8点开始营业,一共有3种座位(2人座,4人座,6人座),每次来一批客人 吃饭时间30分钟,下一批没座的客人最多等30分钟模拟!关键在于存储每种座位什么时候是空的,或者说什么时候客人会离开,可以用队列来存储!(题目给定的就是按时间顺序的)View Code 1 #include<stdio.h> 2 #include<algorithm> 3 #include<stdlib.h> 4 #include<queue> 5 using namespace std; 6 const int maxn = 1005; 7 struct n 阅读全文
posted @ 2013-02-06 19:35 xxx0624 阅读(586) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<algorithm> 4 #include<stdlib.h> 5 using namespace std; 6 const int maxn = 205; 7 char a[ maxn ],b[ maxn ],s[ maxn ]; 8 char fi[ 505 ][ maxn ]; 9 char tmp[ maxn ]; 10 11 void a_b_add( ){ 12 int i,t,la,lb; 13 i=0; 14 阅读全文
posted @ 2013-02-05 22:06 xxx0624 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 打表找范围!View Code 1 #include<stdio.h> 2 int fac[ 12 ]; 3 void init(){ 4 fac[ 0 ]=1; 5 fac[ 1 ]=1; 6 fac[ 2 ]=2; 7 for( int i=3;i<=9;i++ ){ 8 fac[ i ]=fac[ i-1 ]*i; 9 }10 }11 void init2(){12 init();13 printf("1\n2\n");14 for( int i=145;i<=50000;i++ ){15 ... 阅读全文
posted @ 2013-02-05 21:53 xxx0624 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 题意:给定n个点,n-1条边,每两个点之间的路独一无二LCAView Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 const int maxn = 40005; 5 int head[ maxn ],cnt; 6 struct node{ 7 int u,val,next; 8 }edge[ maxn*2 ]; 9 int ace[ maxn ],fa[ maxn ],dis[ maxn ],deep[ maxn ];10 void init(){11 cnt=0; 阅读全文
posted @ 2013-02-05 20:06 xxx0624 阅读(371) 评论(0) 推荐(0) 编辑
摘要: 详见代码View Code 1 //设n可以表示成i个连续整数之和,首项为a, 2 //则n=a+(a+1)+……(a+i-1)=i*a+(1+2+……+(i-1))=i*a+(i*(i-1)/2)-->a=(n-(i*(i-1)/2))/i 3 //枚举i,使得a右边能整除,ans++ 4 #include<stdio.h> 5 int main(){ 6 int n; 7 while( scanf("%d",&n)!=-1 ){ 8 int sum=0,i; 9 for( i=1;i<=n;i++ ){10 sum... 阅读全文
posted @ 2013-02-04 23:10 xxx0624 阅读(255) 评论(0) 推荐(0) 编辑
上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 42 下一页