04 2012 档案

 
HDU 4217 Data Structure?
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4217经典的线段树问题,找第k小数。注意sum用__int64View Code #include <stdio.h>#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const int maxn=300000;int tree[maxn<<2];int temp;void build(int l,int r,int rt){ tree[rt]=r-l+1; if(l==r) return; int m=(l+r)& 阅读全文
posted @ 2012-04-29 22:14 LegendaryAC 阅读(340) 评论(0) 推荐(0)
HDU 2140 Michael Scofield's letter
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2140按题意翻译字符串View Code #include <stdio.h>#include <string.h>int main(){ char tab[10][2]={{'b',' '},{'q',','},{'t','!'},{'m','l'},{'i','e'},{'c','a'},{& 阅读全文
posted @ 2012-04-26 18:09 LegendaryAC 阅读(261) 评论(0) 推荐(0)
HDU 1212 Big Number
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1212大整数取模问题(a+b) mod n=((a mod n)+(b mod n)) mod nView Code #include <stdio.h>#include <string.h>int main(){ char s[1100]; int n; int len,ans,i; while(~scanf("%s%d",s,&n)) { len=strlen(s); ans=0; for(i=0;i<len;i++) ... 阅读全文
posted @ 2012-04-26 17:23 LegendaryAC 阅读(202) 评论(0) 推荐(1)
HDU 2710 Max Factor
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2710找出拥有最大素因子的数,基本的素数筛选View Code #include <stdio.h>int prime[110000];int main(){ int t,n; int i,j; int max,maxnum; for(i=2;i*i<=100001;i++) if(!prime[i]) for(j=i;j*i<=100001;j++) prime[i*j]=1; while(~scanf("%d"... 阅读全文
posted @ 2012-04-26 16:17 LegendaryAC 阅读(296) 评论(0) 推荐(0)
HDU 1339 A Simple Task
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1339n=o*2^p,已知n,求o和p水、、、View Code #include <stdio.h>#include <string.h>int main(){ int t,n; int cnt; scanf("%d",&t); while(t--) { scanf("%d",&n); if(n%2) printf("%d 0\n",n); else { cnt=0; ... 阅读全文
posted @ 2012-04-26 13:06 LegendaryAC 阅读(163) 评论(0) 推荐(0)
HDU 1391 Number Steps
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1391水View Code #include <stdio.h>#include <string.h>int main(){ int t; int x,y; scanf("%d",&t); while(t--) { scanf("%d%d",&x,&y); if(x!=y&&x!=y+2) puts("No Number"); else { if(y%2) ... 阅读全文
posted @ 2012-04-26 12:48 LegendaryAC 阅读(152) 评论(0) 推荐(0)
HDU 1496 Equations
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1496今天刚知道这种方法叫哈希。。。开始没考虑清楚边界,各种错,A了再看也就那么回事View Code #include <stdio.h>#include <string.h>const int N=1000000;int hash[2000001];int main(){ int a,b,c,d; int ans; int i,j; while(~scanf("%d%d%d%d",&a,&b,&c,&d)) { if((a> 阅读全文
posted @ 2012-04-26 12:33 LegendaryAC 阅读(191) 评论(0) 推荐(0)
HDU 1491 Octorber 21st
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1491无聊题View Code #include <stdio.h>int main(){ int t,i; int month,day,now; int tab[11]={0,31,28,31,30,31,30,31,31,30}; scanf("%d",&t); while(t--) { scanf("%d%d",&month,&day); if(month>10||(month==10&&day>21 阅读全文
posted @ 2012-04-26 11:18 LegendaryAC 阅读(200) 评论(0) 推荐(0)
HDU 1176 免费馅饼
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1176类似数塔的dp,注意边界处理!!!View Code #include <stdio.h>#include <string.h>int dp[110000][30];int max3(int a,int b,int c){ int maxnum=a; if(maxnum<b)maxnum=b; if(maxnum<c)maxnum=c; return maxnum;}int max2(int a,int b){ return a>b?a:b;}int main( 阅读全文
posted @ 2012-04-25 22:12 LegendaryAC 阅读(163) 评论(0) 推荐(0)
HDU 1492 The number of divisors(约数) about Humble Numbers
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1492计算约数的个数,由已知条件"A number whose only prime factors are 2,3,5 or 7 is called a humble number."简化运算。View Code #include <stdio.h>__int64 find(__int64 n,int a){ __int64 ans=0; while(1) { if(n==1)break; if(n%a==0) { ans++... 阅读全文
posted @ 2012-04-25 03:24 LegendaryAC 阅读(259) 评论(0) 推荐(0)
HDU 1593 find a way to escape
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1593吐槽:大晚上的说好复习高数又有点变味儿了、、、囧这道题问的是怎么能够逃脱。开始写的直接往相反方向跑,wa了,查别人的解题报告说找同心圆使两人角速度相等,然后再往反方向跑。代码很简单,但不太容易想。ps:角速度w=v/rView Code #include <stdio.h>#define PI 3.1415926535int main(){ double r,v1,v2; while(~scanf("%lf%lf%lf",&r,&v1,&v2)) 阅读全文
posted @ 2012-04-25 03:05 LegendaryAC 阅读(261) 评论(0) 推荐(0)
BJTU 1188 素数筛选
摘要:http://acm.bjtu.edu.cn/problem/detail?pid=1188百万级素数筛选,果断埃斯托拉尼筛法View Code #include <stdio.h>int prime[1000001];int ans[1000001]={0,0,1};int main(){ int i,j,n; for(i=2;i*i<=1000000;i++) if(!prime[i]) for(j=i;j*i<=1000000;j++) prime[j*i]=1; for(i=3;i<=1000000;i... 阅读全文
posted @ 2012-04-25 01:51 LegendaryAC 阅读(198) 评论(0) 推荐(0)
HDU 1087 Super Jumping! Jumping! Jumping!
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1087求最长上升子序列问题View Code #include <stdio.h>#include <string.h>#include <stdlib.h>int cmp(const void*a,const void*b){ return *(int*)b-*(int*)a;}int main(){ int n,i,j; int a[1100],dp[1100]; while(scanf("%d",&n),n) { for(i=0;i< 阅读全文
posted @ 2012-04-24 21:30 LegendaryAC 阅读(127) 评论(0) 推荐(0)
HDU 2103 Family planning
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2103bs这道题,我坚信生男生女都一样!ps:不提前把几个0打出来的话要用__int64,否则会超范围View Code #include <stdio.h>int main(){ int t,m,n; int i; int bb,cnt,f; __int64 ans,fj; scanf("%d",&t); while(t--) { cnt=ans=f=0; fj=10000; scanf("%d%d",&m,&n); ... 阅读全文
posted @ 2012-04-24 20:57 LegendaryAC 阅读(234) 评论(0) 推荐(0)
HDU 1222 Wolf and Rabbit
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1222题意:判断兔纸酱能否存活求最大公约数。分析:如狼能从0到1,则狼能到任意洞。要使狼能到1,则gcd(m,n)=1View Code #include <stdio.h>int gcd(int a,int b){ return a%b==0?b:gcd(b,a%b);}int main(){ int p,m,n; scanf("%d",&p); while(p--) { scanf("%d%d",&m,&n); if(gcd(m, 阅读全文
posted @ 2012-04-23 23:09 LegendaryAC 阅读(166) 评论(0) 推荐(0)
HDU 4104 Discount
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4104第一遍看了眼数据,直接输出所有数的和加1,居然过了,不过我相信一切都是有原因的~View Code #include <stdio.h>int main(){ int n,s,a,i; while(~scanf("%d",&n)) { s=0; for(i=0;i<n;i++) { scanf("%d",&a); s+=a; } printf("%d\n",s+1); ... 阅读全文
posted @ 2012-04-23 22:48 LegendaryAC 阅读(207) 评论(0) 推荐(0)
HDU 2719 The Seven Percent Solution
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2719按要求处理字符串View Code #include <stdio.h>#include <string.h>int main(){ char s[1100]; char tab1[30]={' ','!','$','%','(',')','*'}; char tab2[10][20]={{"%20"},{"%21"},{&quo 阅读全文
posted @ 2012-04-23 22:35 LegendaryAC 阅读(204) 评论(0) 推荐(0)
HDU 2743 Quicksum
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2734按规则计算就行,很简单、、、View Code #include <stdio.h>#include <string.h>int main(){ char s[1100]; char tab[30]={' ','A','B','C','D','E','F','G','H','I','J','K 阅读全文
posted @ 2012-04-23 22:24 LegendaryAC 阅读(205) 评论(0) 推荐(0)
HDU 2700 Parity
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2700读懂了发现就是一个奇偶判断View Code #include <stdio.h>#include <string.h>int main(){ char s[1100]; int len,cnt,i; while(gets(s)) { cnt=0; if(s[0]=='#')break; len=strlen(s); for(i=0;i<len-1;i++) if(s[i]=='1')cnt++; ... 阅读全文
posted @ 2012-04-23 22:15 LegendaryAC 阅读(235) 评论(0) 推荐(0)
HDU 2740 Root of the Problem
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2740题意:找到A,另A^N最接近B思路:逆向考虑,B^(1/n)上下取整,在各取N次幂,看哪个更接近Bps:注意上下取整View Code #include <stdio.h>#include <math.h>int main(){ int b,n; double temp; int p,q; while(scanf("%d%d",&b,&n),(b||n)) { temp=pow(b*1.0,1.0/n); p=floor(temp);//向下取 阅读全文
posted @ 2012-04-23 19:09 LegendaryAC 阅读(222) 评论(0) 推荐(0)
HDU 1789 Doing Homework again
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1789贪心,按价值从大到小排序,然后尽可能的安排到截止时间View Code #include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct L{ int a,b;}L;L kk[1100];int cmp(const void*a,const void*b){ L*c=(L*)a; L*d=(L*)b; if(c->b==d->b) return c->a-d->a; r 阅读全文
posted @ 2012-04-23 14:34 LegendaryAC 阅读(132) 评论(0) 推荐(0)
HDU 2317 Nasty Hacks
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2317题意:判断做不做广告。胡搞题,看眼sample凑活一写就过了View Code #include <stdio.h>int main(){ int n,r,e,c,f; scanf("%d",&n); while(n--) { scanf("%d%d%d",&r,&e,&c); f=r-e+c; if(f<0)puts("advertise"); else if(f==0)puts(" 阅读全文
posted @ 2012-04-22 22:04 LegendaryAC 阅读(222) 评论(0) 推荐(0)
HDU 1257 最少拦截系统
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1257和POJ和2533一模一样。。。View Code #include <stdio.h>#include <string.h>#include <stdlib.h>int cmp(const void*a,const void*b){ return *(int*)b-*(int*)a;}int main(){ int n,i,j; int a[1100],dp[1100]; while(~scanf("%d",&n)) { for(i=0; 阅读全文
posted @ 2012-04-22 21:14 LegendaryAC 阅读(185) 评论(0) 推荐(0)
POJ 2533 Longest Ordered Subsequence
摘要:http://poj.org/problem?id=2533最长上升子序列,dpView Code #include <stdio.h>#include <string.h>#include <stdlib.h>int cmp(const void*a,const void*b){ return *(int*)b-*(int*)a;}int main(){ int n,i,j; int a[1100],dp[1100]; while(~scanf("%d",&n)) { for(i=0;i<n;i++) scanf(&quo 阅读全文
posted @ 2012-04-22 20:55 LegendaryAC 阅读(165) 评论(0) 推荐(0)
HDU 1163 Eddy's digital Roots
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1163脑袋疼的厉害,写完没调试直接交,居然把%d写成%c,导致wa一次。。。这题感觉前两天刚做过一道一样的。。。HDOJ的题目很多无脑重复啊。。View Code #include <stdio.h>int main(){ int n; int i,s; while(scanf("%d",&n),n) { s=1; for(i=0;i<n;i++) s=s*n%9; if(s==0) printf("... 阅读全文
posted @ 2012-04-22 16:29 LegendaryAC 阅读(177) 评论(0) 推荐(0)
HDU 1231 最大连续子序列
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1231最大连续子序列,水View Code #include <stdio.h>#include <stdlib.h>int cmp(const void*a,const void*b){ return *(int*)b-*(int*)a;}int a[110000];int main(){ int n,i; int max,now; int start,end; int temp; int p,q; while(scanf("%d",&n),n) { .. 阅读全文
posted @ 2012-04-21 20:17 LegendaryAC 阅读(172) 评论(0) 推荐(0)
HDU 2571 命运
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2571dp。wa两次,设边从1开始,所以和0有关的除了ans[1][0]和ans[0][1]外都要初始化为无穷(不让从外面进来)View Code #include <stdio.h>int map[30][1100];int ans[30][1100];#define INF -100000000int max(int a,int b){ return a>b?a:b;}int main(){ int n,m; int t; int i,j,k; scanf("%d", 阅读全文
posted @ 2012-04-21 20:05 LegendaryAC 阅读(165) 评论(0) 推荐(0)
HDU 4224 Enumeration?
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4224。。。对这题目无语了,本来是秒杀的题目就是让你读不懂。。。View Code #include <stdio.h>#include <string.h>#include <stdlib.h>int main(){ int x1,y1,x2,y2,x3,y3; int t,nCase=1; scanf("%d",&t); while(t--) { scanf("%d%d%d%d%d%d",&x1,&y1,& 阅读全文
posted @ 2012-04-21 16:53 LegendaryAC 阅读(335) 评论(0) 推荐(0)
HDU 4147 KFC -Z+W
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4147小学生英文阅读题View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#define INF 100000000int main(){ int n,B,D,f,F; int sum,min,len; int i,j; char s[1100]; while(~scanf("%d%d%d%d%d%*c",&n,&B,&D,&f,&F) 阅读全文
posted @ 2012-04-21 16:25 LegendaryAC 阅读(257) 评论(0) 推荐(0)
HDU 4148 Length of S(n)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4148找规律,后一项描述前一项每一段有多少连续的相同数字。ps:算到30项,总共的长度也不小了,开始s数组开小了,一直运行出错,郁闷好一会View Code #include <stdio.h>#include <string.h>#include <stdlib.h>char s[40][11000];int main(){ int n,i,j; int cnt,f; s[1][0]='1'; s[1][1]='\0'; for(i=2;i 阅读全文
posted @ 2012-04-21 15:44 LegendaryAC 阅读(284) 评论(0) 推荐(0)
HDU 1326 Box of Bricks
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1326水,不过PE两次,囧View Code #include <stdio.h>#include <stdlib.h>int cmp(const void*a,const void*b){ return *(int*)b-*(int*)a;}int main(){ int n,i,s,av,bz; int h[60]; int nCase=1; while(scanf("%d",&n),n) { s=bz=0; for(i=0;i<n;i++)... 阅读全文
posted @ 2012-04-21 14:26 LegendaryAC 阅读(241) 评论(0) 推荐(0)
HDU 1298 Hat’s IEEE
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1289对二进制数进行位运算。首先可以百度一下IEEE 754的规则。以6560.91为例:6560.91的二进制表示为1100110100000.111010001111010111,写成科学计数法就是1.100110100000111010001111010111 * 2^12s有一位,是符号位,为正数,符号位是0。e有八位,代表二进制数的指数,这时e就是12(sample输出的第一个数)。f代表有效部分,有23位,为100110100000111010001111010111 。所以,符号位是0然后用它的 阅读全文
posted @ 2012-04-21 14:03 LegendaryAC 阅读(216) 评论(0) 推荐(0)
AHU 501 送钱活动
摘要:http://icpc.ahu.edu.cn/OJ/Problem.aspx?id=501和hdu1024一模一样,随便改改就过了。。。ps:安徽大学oj这个经验值系统真好玩、、View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#define INF -100000000int max(int a,int b){ return a>b?a:b;}int a[1100000],p[1100000],q[1100000],now[1100000],pro[1100000];/ 阅读全文
posted @ 2012-04-21 00:13 LegendaryAC 阅读(219) 评论(0) 推荐(0)
HDU 1024 Max Sum Plus Plus
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1024求m个子段的最大和。思路见代码注释。View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#define INF -100000000int max(int a,int b){ return a>b?a:b;}int a[1100000],now[1100000],pro[1100000];//now记录当前最大值,pro记录前一个的最大值 int main(){ int n,m,i, 阅读全文
posted @ 2012-04-21 00:05 LegendaryAC 阅读(216) 评论(0) 推荐(0)
HDU 3752 Is the one been second-killed first?
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3752捅死一只萌萌~View Code #include <stdio.h>int main(){ int t,m,n,i; scanf("%d",&t); while(t--) { scanf("%d%d",&m,&n); for(i=0;i<n-1;i++) m-=2; puts(m%2?"NO":"YES"); } return 0;} 阅读全文
posted @ 2012-04-20 00:40 LegendaryAC 阅读(194) 评论(0) 推荐(0)
HDU 2537 8球胜负
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2537模拟View Code #include <stdio.h>char a[100];int n;int gao(){ int r,y,i; r=y=7; for(i=0;i<n;i++) { if(a[i]=='R')r--; if(a[i]=='Y')y--; if(a[i]=='B'&&r==0)return 1; if(a[i]=='B'&&r!=0)return 0; if(a[i] 阅读全文
posted @ 2012-04-20 00:19 LegendaryAC 阅读(224) 评论(0) 推荐(0)
HDU 1106 排序
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1106直接做不太方便,在网上新学一招。atoi这个函数原来做进制转换的时候就接触过。如果第一个非空格字符不存在或者不是数字也不是正负号则返回零,否则开始做类型转换,之后检测到非数字(包括结束符 \0) 字符时停止转换,返回整型数。(百度百科)简而言之是一个把字符型数字转化成整型的函数。strtok函数,感觉这个比较新鲜。下面从百度百科摘点介绍:原型 char *strtok(char *s, const char *delim);功能 分解字符串为一组字符串。s为要分解的字符串,delim为分隔符字符串。.. 阅读全文
posted @ 2012-04-19 22:26 LegendaryAC 阅读(1972) 评论(0) 推荐(1)
HDU 1013 Digital Roots
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1013按要求模拟View Code #include <stdio.h>#include <string.h>int main(){ int n; char a[1100]; while(gets(a)) { if(a[0]=='0')break; int len=strlen(a); n=0; for(int i=0;i<len;i++) { n+=a[i]-'0'; n... 阅读全文
posted @ 2012-04-19 21:13 LegendaryAC 阅读(189) 评论(1) 推荐(0)
HDU 1718 Rank
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1718求给定学号在所有人里面的排名View Code #include <stdio.h>int main(){ int gd; int a[1100],b[1100]; int i; while(~scanf("%d",&gd)) { int cnt=0; while(scanf("%d%d",a+cnt,b+cnt),(a[cnt]||b[cnt])) cnt++; for(i=0;i<cnt;i++) ... 阅读全文
posted @ 2012-04-19 17:12 LegendaryAC 阅读(208) 评论(0) 推荐(0)
HDU 2143 box
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2143除数为0re一次,用除法wa一次,加减互逆,乘除互逆,二者有一即可,这道题用除法会出问题。View Code #include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>__int64 a,b,c;int gao(){ if(a*b==c||a*c==b||b*c==a||a+b==c||a+c==b||b+c==a)return 1; if(a!=0) if(b%a== 阅读全文
posted @ 2012-04-19 16:34 LegendaryAC 阅读(215) 评论(0) 推荐(0)
HDU 2148 Score
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2148View Code #include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>int main(){ int t,n,l; int i; int s[1100]; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&l); for(i=1;i<=n;i++) s 阅读全文
posted @ 2012-04-19 16:07 LegendaryAC 阅读(155) 评论(0) 推荐(0)
HDU 1847 Good Luck in CET-4 Everybody!
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1847如果j-A[i]是必败态,j就是必胜态,显然0必败,一个dp的过程#include #include #include using namespace std;int A[15], win[1005];int... 阅读全文
posted @ 2012-04-19 15:46 LegendaryAC 阅读(232) 评论(0) 推荐(0)
HDU 2192 MagicBuilding
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2192求出现的最多的那个数字出现的次数参考祖宗的方法搞的,排序+扫。View Code #include <stdio.h>#include <string.h>#include <stdlib.h>int cmp(const void*a,const void*b){ return *(int*)a-*(int*)b;}int a[11000];int main(){ int t,n,i; int s,ans; scanf("%d",&t); 阅读全文
posted @ 2012-04-19 15:39 LegendaryAC 阅读(205) 评论(0) 推荐(0)
HDU 1691 Chinese Chess
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1691博客里面不好骂人,所以就不说太多了。有几点注意:1、象可能跑到不可能达到的位置2、兵要判断后退这种情况View Code 1 #include <stdio.h> 2 3 int map[20][20]; 4 int Kinga,Kingb;//红王坐标 5 int Kingc,Kingd;//黑王坐标 6 int abs(int a){return a>0?a:-a;} 7 int KingFaceToFace()//两王是否相对 8 { 9 int i; 10 ... 阅读全文
posted @ 2012-04-19 11:46 LegendaryAC 阅读(407) 评论(0) 推荐(0)
HDU 3352 Tiles of Tetris, NOT!
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3352View Code #include <stdio.h>int gcd(int a,int b){ return a%b==0?b:gcd(b,a%b);}__int64 lcg(int a,int b){ return (__int64)a*(__int64)b/(__int64)gcd(a,b)/(__int64)gcd(a,b);} int main(){ int a,b; while(scanf("%d%d",&a,&b),(a||b)) prin 阅读全文
posted @ 2012-04-19 01:55 LegendaryAC 阅读(229) 评论(0) 推荐(0)
HDU 1673 Optimal Parking
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1673阅读题View Code #include <stdio.h>#include <stdlib.h>int cmp(const void*a,const void*b){ return *(int*)a-*(int*)b;}int main(){ int t,n,i; int x[30]; scanf("%d",&t); while(t--) { scanf("%d",&n); for(i=0;i<n;i++) sca 阅读全文
posted @ 2012-04-18 21:29 LegendaryAC 阅读(274) 评论(0) 推荐(0)
HDU 1279 验证角谷猜想
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1279按要求模拟View Code #include <stdio.h>int main(){ int t,n,p,f,f1; scanf("%d",&t); while(t--) { f=f1=1; scanf("%d",&n); p=n; while(n) { if(n%2&&n!=1){ f1=0; break; ... 阅读全文
posted @ 2012-04-17 00:13 LegendaryAC 阅读(212) 评论(0) 推荐(0)
HDU 1071 The area
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1071按要求求出面积即可View Code #include <stdio.h>int main(){ int t; double x0,y0,x1,y1,x2,y2; double k,b; double a; double s; scanf("%d",&t); while(t--) { scanf("%lf%lf%lf%lf%lf%lf",&x0,&y0,&x1,&y1,&x2,&y2); k=(y 阅读全文
posted @ 2012-04-16 23:39 LegendaryAC 阅读(194) 评论(0) 推荐(0)
HDU 4218 IMBA?
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4218不用删最后的空格,fuckView Code #include <stdio.h>#include <math.h>int main(){ int t,r,a; int i,j; int nCase=1; scanf("%d",&t); while(t--) { scanf("%d",&r); a=2*r+1; printf("Case %d:\n",nCase++); for(i=0;i<a;i+ 阅读全文
posted @ 2012-04-16 21:51 LegendaryAC 阅读(173) 评论(0) 推荐(0)
HDU 4223 Dynamic Programming?
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4223View Code #include <stdio.h>#include <stdlib.h>#include <string.h>#define INF 100000000int cmp(const void*a,const void*b){ return *(int*)a-*(int*)b;}int a[110000],s[110000];int main(){ int t,n; int i; int min; int nCase=1; scanf("% 阅读全文
posted @ 2012-04-16 21:46 LegendaryAC 阅读(194) 评论(0) 推荐(0)
HDU 1003 Max Sum
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1003靠,总算过了,不解释View Code #include <stdio.h>#include <stdlib.h>int a[110000];int main(){ int t,n; int i,f; int max,now; int start,end; int temp; int nCase=1; scanf("%d",&t); f=0; while(t--) { scanf("%d",&n); scanf(" 阅读全文
posted @ 2012-04-16 18:47 LegendaryAC 阅读(144) 评论(0) 推荐(0)
HDU 4221 Greedy?
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4221哎,这么简单一道题,愁View Code #include <stdio.h>#include <stdlib.h>typedef struct L{ __int64 c,d;}L;L kk[110000];int cmp(const void*a,const void*b){ return (*(L*)a).d-(*(L*)b).d;}int main(){ int t,n; int i; __int64 time,py; int nCase=1; scanf... 阅读全文
posted @ 2012-04-15 21:13 LegendaryAC 阅读(210) 评论(0) 推荐(0)
HDU 1205 吃糖果
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1205max为最大堆数量,s为总数。保证max-(s-max)=2*max-s<=1即可,因为只要能保证最大堆数量和其他堆数量差在一个以内,就可以做到别的堆拿一个最大堆拿一个(剩下yy)这种操作。View Code #include <stdio.h>int a[1100000];int main(){ int t,n; int i; __int64 s; int max; scanf("%d",&t); while(t--) { s=max=0; ... 阅读全文
posted @ 2012-04-14 19:08 LegendaryAC 阅读(392) 评论(0) 推荐(0)
HDU 2540 遮挡判断
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2540只要影子长度大于前面的所有影子长度就okView Code #include <stdio.h>#include <stdlib.h>typedef struct node{ int x,h;}node;node kk[110000];int cmp(const void*a,const void*b){ return (*(node*)a).x-(*(node*)b).x;}int main(){ int n,i; int A,T; while(scanf("%d&q 阅读全文
posted @ 2012-04-14 10:16 LegendaryAC 阅读(232) 评论(0) 推荐(0)
HDU 2108 Shape of HDU
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2108几何计算,判断线段的转向。View Code #include <stdio.h>#include <string.h>#include <math.h>typedef struct point{ int x,y; }point;point kk[100000];int dis(point p1,point p2,point p3){ return (p3.x-p1.x)*(p2.y-p1.y)-(p2.x-p1.x)*(p3.y-p1.y);}int main(){ 阅读全文
posted @ 2012-04-13 23:29 LegendaryAC 阅读(187) 评论(0) 推荐(0)
HDU 3783 ZOJ
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3783View Code #include <stdio.h>#include <stdlib.h>#include <string.h> int main(){ int n,i; int cntZ,cntO,cntJ; int len; char str[200]; while(gets(str)) { if(str[0]=='E')break; len=strlen(str); cntZ=cntO=cntJ=0; ... 阅读全文
posted @ 2012-04-13 22:31 LegendaryAC 阅读(229) 评论(0) 推荐(0)
HDU 3782 xxx定律
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3782View Code #include <stdio.h>#include <stdlib.h>int main(){ int n; while(scanf("%d",&n),n) { int cnt=0; while(1) { if(n==1)break; if(n&1) n=(3*n+1)>>1; else n>>=1... 阅读全文
posted @ 2012-04-13 22:07 LegendaryAC 阅读(165) 评论(0) 推荐(0)
HDU 3785 寻找大富翁
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3785View Code #include <stdio.h>#include <stdlib.h>#define INF 200000000int cmp(const void*a,const void*b){ return *(int*)b-*(int*)a;}int a[110000];int main(){ int n,m; while(scanf("%d%d",&n,&m),(n||m)) { for(int i=0;i<100001 阅读全文
posted @ 2012-04-13 22:02 LegendaryAC 阅读(225) 评论(0) 推荐(0)
HDU 2399 GPA
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2399最短路最小生成树神马的几道题纠结了几个小时,换换心情吧。直接按题目要求做。View Code #include <stdio.h>#include <string.h>int main(){ char str[300]; int len,i; int s,f,cnt; while(gets(str)) { len=strlen(str); s=f=cnt=0; for(i=0;i<len;i++) { ... 阅读全文
posted @ 2012-04-13 13:49 LegendaryAC 阅读(403) 评论(0) 推荐(0)
HDU 1879 继续畅通工程
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1879最小生成树。。。m,n又看反了。。。无语ingView Code #include #include #include int idx[1000000];struct node{ int a,b,cos... 阅读全文
posted @ 2012-04-13 13:09 LegendaryAC 阅读(145) 评论(0) 推荐(0)
HDU 1863 畅通工程
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1863裸的最小生成树,只需多判断一下是否连通,我用的方法是看是否只有一个根节点。ps:m和n写反了,害我查了1h啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊View Code #include #include #include... 阅读全文
posted @ 2012-04-13 10:12 LegendaryAC 阅读(208) 评论(0) 推荐(0)
HDU 1233 还是畅通工程
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1233最小生成树,查找根节点的函数里面等号写成赋值号,查了半个小时、、、View Code #include #include #define N 110int idx[N];struct node{ int... 阅读全文
posted @ 2012-04-13 09:06 LegendaryAC 阅读(145) 评论(0) 推荐(0)
HDU 1202 The calculation of GPA
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1202刚开始没看到输入实数。。。汗、、、View Code #include <stdio.h>int main(){ double s[100],p[100]; int n,i; double ss,sp; int cnt; while(~scanf("%d",&n)) { cnt=ss=sp=0; for(i=0;i<n;i++) { scanf("%lf%lf",s+i,p+i); ... 阅读全文
posted @ 2012-04-12 00:10 LegendaryAC 阅读(193) 评论(0) 推荐(0)
HDU 1248 寒冰王座
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1248我乱搞的,标准做法01背包View Code #include <stdio.h>int test(int n){ if(n<150)return n; if(n>200&&n<300)return n-200; return n%50;}int main(){ int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); printf("%d\n 阅读全文
posted @ 2012-04-11 23:49 LegendaryAC 阅读(194) 评论(0) 推荐(0)
HDU 1234 开门人和关门人
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1234和祖宗随机题号PK,由于这题first和end的初值赋反了,导致调试10分钟,最后以惨败收场。。。View Code #include <stdio.h>#include <string.h>#define INF 100000000int main(){ int t,n,i; int hb,mb,sb; int he,me,se; int first,end; char name[2][200],namec[200]; scanf("%d",&t); 阅读全文
posted @ 2012-04-11 22:29 LegendaryAC 阅读(363) 评论(0) 推荐(0)
HDU 1181 变形课
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1181直接bfs,等号写成赋值了,wa两次。。。View Code #include <stdio.h>#include <string.h>char s[200];char graph[50][50];char vis[50];int q[50];int bfs(){ int front=0,rear=1; int ch,i; q[0]=1; while(front<rear) { ch=q[front++]; if(ch=='m'-'a')re 阅读全文
posted @ 2012-04-11 13:04 LegendaryAC 阅读(212) 评论(0) 推荐(0)
HDU 2116 Has the sum exceeded
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2116判断两个k位带符号数的和有木有溢出。判断的时候注意不能用两个数的和判断,否则溢出的话会有bug。这里的方法是用最值减其中一个数,再和另一个数比较。View Code #include <stdio.h>int k;__int64 a,b;__int64 pow(int x,int y){ int i; __int64 s=1; for(i=0;i<y;i++) s*=x; return s;}#define MAX pow(2,63) int test(){ ... 阅读全文
posted @ 2012-04-11 12:33 LegendaryAC 阅读(252) 评论(0) 推荐(0)
HDU 1283 最简单的计算机
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1283模拟View Code #include <stdio.h>int main() { int m1,m2,r1,r2,r3,i; char s[300]; while(~scanf("%d%d",&m1,&m2)) { scanf("%s",s); r1=r2=r3=0; for(i=0;s[i];i++) { switch(s[i]) { ... 阅读全文
posted @ 2012-04-11 00:23 LegendaryAC 阅读(221) 评论(0) 推荐(0)
HDU 2552 三足鼎立
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2552数学推导View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>int main(){ int t; scanf("%d",&t); while(t--) { scanf("%*lf%*lf"); printf("1\n"); } return 0;} 阅读全文
posted @ 2012-04-10 17:31 LegendaryAC 阅读(178) 评论(0) 推荐(0)
HDU 1213 How Many Tables
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1213和畅通工程是一个意思、、View Code #include #include #include int idx[2000];int n,m;int find(int x){ //找x所在并查集的根节点... 阅读全文
posted @ 2012-04-10 16:25 LegendaryAC 阅读(202) 评论(0) 推荐(0)
HDU 1232 畅通工程
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1232第一次做并查集,有点小爽。。。View Code #include #include #include int idx[2000];int n,m;int find(int x){ //找x所在并查集的... 阅读全文
posted @ 2012-04-10 16:11 LegendaryAC 阅读(156) 评论(0) 推荐(0)
HDU 2131 Probability
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2131求字母在单词中出现的概率,无视大小写View Code #include <stdio.h>#include <string.h>#include <stdlib.h>int main(){ char sp,word[210]; int i,len,cnt; while(~scanf("%c%s%*c",&sp,word)) { len=strlen(word); cnt=0; for(i=0;i<len;i++) ... 阅读全文
posted @ 2012-04-09 23:56 LegendaryAC 阅读(199) 评论(0) 推荐(0)
HDU 2523 SORT AGAIN
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2523求差的绝对值第k大的数,注意相同的差算一个。分析出差的绝对值在[0,2000]这个范围内,由此可以搞出hash数组View Code #include <stdio.h>#include <string.h>#include <stdlib.h>int abs(int a){ return a>0?a:-a;}int a[3000],hash[5000];int main(){ int t,n,k; int i,j; scanf("%d",& 阅读全文
posted @ 2012-04-09 23:31 LegendaryAC 阅读(210) 评论(0) 推荐(0)
HDU 1196 Lowest Bit
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1196按要求直接做View Code #include <stdio.h>int pow(int a,int b){ int i,s=1; for(i=0;i<b;i++) s*=a; return s;}int main(){ int n,cnt,y; while(scanf("%d",&n),n) { cnt=0; while(1) { y=n%2; n/=2; ... 阅读全文
posted @ 2012-04-09 20:48 LegendaryAC 阅读(140) 评论(0) 推荐(0)
HDU 2521 反素数
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2521题目蒙人,这题和反素数没关系求一个区间内因子数最多的最小的数View Code #include <stdio.h>#include <string.h>int main(){ int t,a,b,i,j; int cnt[6000]; int max,si; memset(cnt,0,sizeof(cnt)); cnt[1]=1; for(i=2;i<5001;i++) { for(j=2;j<=i/2;j++) if(i%... 阅读全文
posted @ 2012-04-09 14:05 LegendaryAC 阅读(306) 评论(0) 推荐(0)
HDU 2190 悼念512汶川大地震遇难同胞——重建希望小学
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2190考虑两种砖,得出递推公式。a[i]=a[i-1]+2*a[i-2]View Code #include <stdio.h>int main(){ int n,i; __int64 a[40]={0,1,3}; for(i=3;i<=30;i++) a[i]=a[i-1]+2*a[i-2]; scanf("%d",&n); while(n--) { scanf("%d",&i); printf("%I64d\n" 阅读全文
posted @ 2012-04-09 12:54 LegendaryAC 阅读(692) 评论(0) 推荐(0)
HDU 2187 悼念512汶川大地震遇难同胞——老人是真饿了
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2187与2111一样,直接贪心即可View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>struct node{ int p,m;}kk[1100];int cmp(const void*a,const void*b){ struct node*c=(struct node*)a; struct node*d=(struct node*)b; retu 阅读全文
posted @ 2012-04-09 12:15 LegendaryAC 阅读(275) 评论(0) 推荐(0)
HDU 2111 Saving HDU
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2111直接贪心View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>struct node{ int p,m;}kk[110];int cmp(const void*a,const void*b){ struct node*c=(struct node*)a; struct node*d=(struct node*)b; return d->p- 阅读全文
posted @ 2012-04-09 11:28 LegendaryAC 阅读(179) 评论(0) 推荐(0)
HDU 1995 汉诺塔V
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1995列表画一下,规律即出View Code #include <stdio.h>#include <string.h>#include <stdlib.h>__int64 pow(int a,int b){ int i; __int64 s=1; for(i=0;i<b;i++) s*=a; return s;}__int64 dp[70][70];int main(){ int t,n,m,i,j; for(i=1;i<61;i++) for... 阅读全文
posted @ 2012-04-09 10:47 LegendaryAC 阅读(190) 评论(0) 推荐(0)
HDU 1564 Play a game
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1564View Code #include <stdio.h>int main(){ int n; while(scanf("%d",&n),n) { if(n%2==0) printf("8600\n"); else printf("ailyanlu\n"); } return 0;} 阅读全文
posted @ 2012-04-09 00:01 LegendaryAC 阅读(168) 评论(0) 推荐(0)
HDU 1032 The 3n + 1 problem
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1032可能存在i>j的情况,此情况下i,j要按原顺序输出View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>int main(){ int a,b,n,cnt,max,t,f; while(~scanf("%d%d",&a,&b)) { max=f=1; if(a>b) { t=a; a=b; ... 阅读全文
posted @ 2012-04-08 22:56 LegendaryAC 阅读(161) 评论(0) 推荐(0)
HDU 1284 钱币兑换问题
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1284dp,转移方程自行yyView Code #include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>int dp[10][40000]; int main(){ int n; dp[0][0]=1; for(int i=1;i<4;i++) for(int j=0;j<32768;j++) dp[i][j]=dp[i-1][j]+dp[i][j-i]; wh 阅读全文
posted @ 2012-04-08 17:43 LegendaryAC 阅读(146) 评论(0) 推荐(0)
HDU 1397 Goldbach's Conjecture
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1397和2136有共通之处,学习了构造素数表的方法,在这里初次使用。按因子从小到大的顺序筛选,去掉2的倍数,去掉3的倍数......最后剩下的就是素数了。View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>int prime[40000];int main(){ int n; for(int i=2;i*i<32768;i++) { if(!p 阅读全文
posted @ 2012-04-08 16:01 LegendaryAC 阅读(222) 评论(0) 推荐(0)
HDU 2136 Largest prime factor
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2136求n的最大素因子在素数表中的位置。如代码循环,因为如果在前面被计算过则肯定不是素数。View Code #include <stdio.h>#include <string.h> #include <stdlib.h>#include <math.h>int rank[1100000]; int main() { int n,cnt=1; for(int i=2;i<1000001;i++) { if(rank[i])continue; for(in 阅读全文
posted @ 2012-04-08 12:05 LegendaryAC 阅读(279) 评论(0) 推荐(0)
HDU 1062 Text Reverse
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1062每个单词逆序输出就可以View Code #include <stdio.h>#include <string.h> #include <stdlib.h>#include <math.h>int main() { int t,len; int i,j; char a[1100]; scanf("%d%*c",&t); while(t--) { gets(a); len=strlen(a); for(i=0;i<le... 阅读全文
posted @ 2012-04-08 02:05 LegendaryAC 阅读(217) 评论(0) 推荐(0)
HDU 4150 Powerful Incantation
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4150查找不重复字串View Code #include <stdio.h>#include <string.h> #include <stdlib.h>#include <math.h>char a[1100000],b[10]; int main() { int t,ans; int len1,len2; int cnt; scanf("%d%*c",&t); while(t--) { scanf("%s%s%*c&qu 阅读全文
posted @ 2012-04-07 22:15 LegendaryAC 阅读(230) 评论(0) 推荐(0)
HDU 4144 Bacon's Cipher
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4144数字对应1,字母对应0,五位一算。View Code #include <stdio.h>#include <string.h> #include <stdlib.h>int pow(int a,int b) { int i,s=1; for(i=0;i<b;i++) s*=a; return s; }char a[11000]; char tab[30]={'A','B','C','D',' 阅读全文
posted @ 2012-04-07 21:24 LegendaryAC 阅读(233) 评论(0) 推荐(0)
HDU 1166 敌兵布阵
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1166线段树,单点增减,区间求和View Code #include <stdio.h>#include <string.h> #include <stdlib.h>#include <math.h>#define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 const int maxn=51000; int sum[maxn<<2]; int nCase=1; int pushup(i 阅读全文
posted @ 2012-04-07 20:03 LegendaryAC 阅读(165) 评论(0) 推荐(0)
HDU 1720 A+B Coming
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=172016进制输入,10进制输出View Code #include <stdio.h>#include <string.h> #include <stdlib.h>#include <math.h>int main() { int a,b; while(~scanf("%x%x",&a,&b)) printf("%d\n",a+b); return 0; } 阅读全文
posted @ 2012-04-07 16:45 LegendaryAC 阅读(226) 评论(0) 推荐(0)
HDU 1754 I Hate It
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1754线段树,单点更新,区间最值。学习自http://www.notonlysuccess.com/index.php/segment-tree-complete/View Code #include <stdio.h>#include <string.h> #include <stdlib.h>#include <math.h>#define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 const 阅读全文
posted @ 2012-04-07 13:27 LegendaryAC 阅读(124) 评论(0) 推荐(0)
HRBUST 1328 相等的最小公倍数
摘要:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1328判断n因式分解后是否是a^b的形式,是则输出NO,反之YESView Code #include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>int jj(int n){ int i,f1=0,f2=0,t; t=n; for(i=2;i<t;i++) { if(!f1) { if(n%.. 阅读全文
posted @ 2012-04-06 00:50 LegendaryAC 阅读(189) 评论(0) 推荐(0)
HDU 1215 七夕节
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1215求N因子的和,从1找到sqrt(n),成对的找,后面的用前面的除View Code #include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>int gao(int n){ int s=0,i,cc; cc=sqrt(n); for(i=1;i<=cc;i++) if(n%i==0&&n/i>cc&&n/i!=n) s+=(i 阅读全文
posted @ 2012-04-05 23:04 LegendaryAC 阅读(241) 评论(0) 推荐(0)
HDU 1282 回文数猜想
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1282两种想法,用字符串处理或是用数字处理,这里数字处理更简单View Code #include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>int IsHw(int n){ int p,ans=0; p=n; while(n) { ans=ans*10+n%10; n/=10; } if(ans==p)return 1; return 0;}int Nx... 阅读全文
posted @ 2012-04-05 19:23 LegendaryAC 阅读(237) 评论(0) 推荐(0)
POJ 1004 Financial Management
摘要:http://poj.org/problem?id=1004求12个数的平均数、、、太无耻了View Code #include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>int main() { double s,a[13]; int i; while(~scanf("%lf",&a[0])) { s=a[0]; for(i=1;i<12;i++) { scanf("%lf",a+i); s+=a[... 阅读全文
posted @ 2012-04-05 12:16 LegendaryAC 阅读(137) 评论(0) 推荐(0)
POJ 2027 No Brainer
摘要:http://poj.org/problem?id=2027判断a<b......脸皮这两天又厚了不少、、、这种题也拿来充数、、、忏悔ingView Code #include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>int main() { int t; int a,b; scanf("%d",&t); while(t--) { scanf("%d%d",&a,&b); if(a<b 阅读全文
posted @ 2012-04-05 12:11 LegendaryAC 阅读(301) 评论(0) 推荐(0)
POJ 2017 Speed Limit
摘要:http://poj.org/problem?id=2017按题意计算路程,直接算View Code #include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>int main() { int n,i; int s[20],t[20]; int ans; while(scanf("%d",&n),n!=-1) { for(i=0;i<n;i++) scanf("%d%d",s+i,t+i); ans=s[0 阅读全文
posted @ 2012-04-05 12:01 LegendaryAC 阅读(176) 评论(0) 推荐(0)
HDU 2601 An easy problem
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=26012932MS......好险注意:(1)n的数据范围(2)j>=i(3)开方拿出来算因为上面三点挂了几次,勉强过关View Code #include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>int main() { __int64 n; int t,i,p; int cnt; scanf("%d",&t); while(t--) { 阅读全文
posted @ 2012-04-05 11:43 LegendaryAC 阅读(257) 评论(0) 推荐(0)
HDU 4143 A Simple Problem
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4143两个for枚举肯定超时,移项因式分解后,只要一个for枚举(y-x)就好了,(y+x)用n去除(y-x)。另外两个小点,关注到(y-x)一定小于等于sqrt(n),并且(y-x)与(y+x)不相等View Code #include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>int main() { int t,n; int i; int f; scanf("% 阅读全文
posted @ 2012-04-05 11:18 LegendaryAC 阅读(258) 评论(0) 推荐(0)
BJTU 1621 A Simple Math Problem
摘要:http://acm.bjtu.edu.cn/problem/detail?pid=1621(1)总矩形数:考虑1行n个,由一个、两个、三个......1*1正方形组成的方法数为n、n-1、n-2......1,和为(n+1)*n/2(2)正方形数:n*m的矩形,不妨设n<m,则最大的矩形为n*n,这样的矩形根据乘法原理有1*(m-n+1)个,依次考虑(n-1)*(n-1)......1*1的矩形,方法数同理可得另附HDU 2524 矩形A+B,与此题一个思路,不过只考虑(1)罢了http://acm.hdu.edu.cn/showproblem.php?pid=2524View Cod 阅读全文
posted @ 2012-04-05 11:11 LegendaryAC 阅读(201) 评论(0) 推荐(0)
HDU 2673 shǎ崽 OrOrOrOrz
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2673排序题,汗。。。View Code #include <stdio.h>#include <stdlib.h>int cmp(const void*a,const void*b){ return *(int*)a-*(int*)b;}int a[11000];int main() { int n; int i,f,cnt1,cnt2; while(~scanf("%d",&n)) { for(i=0;i<n;i++) scanf("%d 阅读全文
posted @ 2012-04-04 13:18 LegendaryAC 阅读(257) 评论(0) 推荐(0)
HDU 2674 N!Again
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2674n大于等于2009时取余为0,只要算2009前面的就okView Code #include <stdio.h>#include <stdlib.h>int main() { int n; int ans,i; while(~scanf("%d",&n)) { ans=1; if(n>=2009) printf("0\n"); else { for(i=1;i<=n;i++) ... 阅读全文
posted @ 2012-04-04 13:05 LegendaryAC 阅读(249) 评论(0) 推荐(0)
BJTU 1623 Problem C. Course Planning
摘要:http://acm.bjtu.edu.cn/problem/detail?pid=1623贪心,关键点是以课程的结束时间为标准排序View Code #include <stdio.h>#include <stdlib.h>struct node{ __int64 x,y;}kk[110000];int cmp(const void*a,const void*b){ struct node*c=(struct node*)a; struct node*d=(struct node*)b; if(d->y==c->y) return d->x-c-&g 阅读全文
posted @ 2012-04-04 12:40 LegendaryAC 阅读(206) 评论(0) 推荐(0)
HDU 2570 迷瘴
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2570这道题WA了十多次,百思不得其解,百度了一组数据12 1 65 7实数运算一定要修正误差View Code #include <stdio.h>#include <stdlib.h>int cmp(const void*a,const void*b){ return *(int*)a-*(int*)b;}int main() { int t,n,cnt; int v,w,p[200]; int i,j,f; double q,rz,ry; scanf("%d" 阅读全文
posted @ 2012-04-04 11:44 LegendaryAC 阅读(528) 评论(0) 推荐(0)