摘要: Girls and BoysAccepted : 50Submit : 213Time Limit : 1000 MSMemory Limit : 65536 KB有N名单身女生和N名单身男生,每个人心中都有一个按喜欢程度对所有异性的排名。每天,所有单身男生都会向自己最喜欢的单身女生表白,而收到表白的女生则会接受她最喜欢的向她表白的男生。于是他们将脱离单身并组成情侣,且永不分离。假设你有读心术,可以知道每个人心中的排名,那么你能够预测最后哪些人将会成为情侣么?Input有多组测试数据。每组测试数据的第一行是一个整数1 ≤ N ≤ 100。接下来N行,每行是一个1到N的排列,代表各个男生对女生的 阅读全文
posted @ 2012-05-21 21:25 朝圣の路 阅读(226) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1701刚开始没看懂题意,不过后来看看别人的才明白,原来是至少的人数必须之多的人数少,以这个作为标度进行逻辑;代码如下:#include"stdio.h"int main( ){ int t,i; double p,q; scanf("%d",&t); while(t--) { scanf("%lf%lf",&p,&q); for(i=1;;i++) { if((int)(p*i/100)<(int)(q*i/100).. 阅读全文
posted @ 2012-05-21 13:42 朝圣の路 阅读(275) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1868没想出来盗用别人的思路:如:15 = 1+2+3+4+5 = 4+5+6 = 7+8,结果为3。设n可以表示成i个连续整数之和,首项为a,则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 所以我们可以按当前程度i从可能的最大长度k到2(若15=15也算则到1)去试,若能求得首项为整数(可以通过是否能整除判断),则可以表示成i个整数之和。#include"stdio.h"in 阅读全文
posted @ 2012-05-21 00:05 朝圣の路 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 代码如下:#include"stdio.h"#include"string.h"#include"stdlib.h"int flag[1005];struct node{ int date,score;}x[1005];int cmp(const void *a,const void *b){ node *aa=(node*)a,*bb=(node*)b; if(aa->score!=bb->score) return bb->score-aa->score; else return aa->date-b 阅读全文
posted @ 2012-05-20 20:28 朝圣の路 阅读(206) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1051这题思路跟1257那道差不多。。。半贪心半dp代码如下:#include"stdio.h"#include"stdlib.h"int a[5005][2],w[5005][2];struct node { int x,y;}bar[5005];int cmp(const void *a,const void *b){ node *aa=(node*)a,*bb=(node*)b; if(aa->x!=bb->x) return aa->x-bb- 阅读全文
posted @ 2012-05-20 03:55 朝圣の路 阅读(409) 评论(0) 推荐(0) 编辑
摘要: 在一堆数里面把这些数分成降序的排列并使所分的组数最少!!代码如下:#include"stdio.h"int min[100000];int main( ){ int n,x,i,j,count; while(~scanf("%d",&n)) { count=1; for(i=1;i<=n;i++) { scanf("%d",&x); for(j=0;j<count;j++)//个人觉得这里是最经典的地方,因为一石二鸟,既找出了离x最近的最小的数又。。。。 if(... 阅读全文
posted @ 2012-05-17 00:27 朝圣の路 阅读(222) 评论(0) 推荐(0) 编辑
摘要: #include"stdio.h"#include"string.h"int tab[4][2]={0,1,1,0,0,-1,-1,0};int vis1[205][205],count,vis2[205][205];int n,m;int note[40002][2];char a[205][205];int yi[2],me[2],con[205][205];void bfs(int x1,int y1,int vis[205][205]){ int xx,yy,x,y,i; int q[40005],rear=1,front=0; q[front] 阅读全文
posted @ 2012-05-16 23:08 朝圣の路 阅读(415) 评论(0) 推荐(0) 编辑
摘要: 唉。。。这两天真是多灾多难啊。。。净碰到蛋疼的题。犯一些蛋疼的错误(这题是在一个判断的地方关系弄错了)。这题的主要原理是多个集合的容斥原理。代码如下:#include"stdio.h"#include"math.h"__int64 prime[10005]={2,3},count=2;__int64 cnt,factor[20];__int64 n,m,ans;void cal(){ int i,j,flag; for(i=5;i<100000;i+=2) { flag=0; for(j=0;j<count;j++) if(i... 阅读全文
posted @ 2012-05-16 14:48 朝圣の路 阅读(345) 评论(0) 推荐(0) 编辑
摘要: 好题啊。。。乍一看是复杂的排列组合问题,其实是:每个盘子都可以放到三个柱子上的任意一个,所以是3^n.经典!!代码如下:#include"stdio.h"int main( ){ __int64 num[31]={1}; int i,t,n; for(i=1;i<=30;i++) num[i]=num[i-1]*3; scanf("%d",&t); while(t--) { scanf("%d",&n); printf("%I64d\n",num[n]); } return 0;} 阅读全文
posted @ 2012-05-14 04:43 朝圣の路 阅读(369) 评论(0) 推荐(1) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1259无语了。。这题刚开始wa了一次,当时把每次变动之后J的位置都默认为2了,太2了。代码如下:#include"stdio.h"int main( ){ int t,m,x,y,p; scanf("%d",&t); while(t--) { scanf("%d",&m); p=2; while(m--) { scanf("%d%d",&x,&y); if(x==p)//刚开始把p写成2... 阅读全文
posted @ 2012-05-14 04:08 朝圣の路 阅读(217) 评论(0) 推荐(0) 编辑