andre_joy

导航

2012年7月1日

hdu 1412

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1412题意:中文……mark:先排序,再一起扫描一遍。代码:#include <stdio.h>#include <stdlib.h>int cmp(const void *a, const void *b){ return *(int *)a - *(int *)b;}int a[10010],b[10010],c[20010];int main(){ int n,m; int i,j,k; while(~scanf("%d%d", &n, & 阅读全文

posted @ 2012-07-01 21:15 andre_joy 阅读(130) 评论(0) 推荐(0) 编辑

hdu 1017

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1017题意:给定n,m,求满足(a^2+b^2+m)/(a*b)仍是整数的(a,b)的组数。mark:n的值比较小,扫描一遍,也就100*100.代码:#include <stdio.h>int main(){ int t,n,m,sum; int i,j,a,b; scanf("%d", &t); for(i = 0; i < t; i++) { if(i) puts(""); j = 1; while(~scanf("%d% 阅读全文

posted @ 2012-07-01 19:43 andre_joy 阅读(173) 评论(0) 推荐(0) 编辑

hdu 1249

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1249题意:中文……mark:此题重在理解推导公式,f(n)=f(n-1)+6*(n-1),化简为:f(n)=3*n*(n-1)+2。 一个三角形的时候,再加一个三角形,每一条变会与第一个三角形的两条边相交,这样增加2个小三角形,即两个面。f(2)=3*2+f(1),再加一个三角形,每一条边会与前两个三角形的四条边相交,形成四个小三角形,f(3)=3*4+f(2),依次类推,即f(n)=3*2*(n-1)+f(n-1)。代码:#include <stdio.h>int main(){ int 阅读全文

posted @ 2012-07-01 18:04 andre_joy 阅读(238) 评论(0) 推荐(0) 编辑

hdu 1014

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1014题意:通过题目给出的递推公式能否得到0-mod-1之间的所有数。mark:wa了一次,把问题想简单了,一位只是一个数能被另一个数整除……其实是判断两个数是否互素。代码:#include <stdio.h>int gcd(int a, int b){return a%b?gcd(b,a%b):b;}int main(){ int m,n; while(~scanf("%d%d", &m, &n)) { printf("%10d%10d &qu 阅读全文

posted @ 2012-07-01 17:25 andre_joy 阅读(81) 评论(0) 推荐(0) 编辑

hdu rank1000

摘要: 今天245题进入hdoj 1000名内。再接再厉! 阅读全文

posted @ 2012-07-01 15:39 andre_joy 阅读(77) 评论(0) 推荐(0) 编辑

hdu 1070

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1070题意:主角要买牛奶,对牛奶的要求是生产日期5天内引用,每天喝200ml,少于200ml的扔掉,商场牛奶均是当天生产。 选取满足要求的单价最小的牛奶,当单价一样,选择容量多的。mark:wa了两次,都是精度问题,在整数问题里面最好不要用浮点数运算。(一般都是除法比较。)代码:#include <stdio.h>#include <string.h>int main(){ char m[100],d[100]; int t,n,a,b,c,aa,bb,cc; scanf(&qu 阅读全文

posted @ 2012-07-01 15:38 andre_joy 阅读(414) 评论(0) 推荐(0) 编辑

hdu 2200

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2200题意:中文……mark:直接公式化简可得(2^(n-1))*(n-2)+1,要是不会化简,可以用递推做f(n)=2*f(n-1)+2^(n-1)-1代码:#include<stdio.h>int main(){ long long n; while (~scanf ("%I64d", &n)) printf ("%I64d\n", (1LL << (n-1)) * (n-2) + 1); return 0;} 阅读全文

posted @ 2012-07-01 15:01 andre_joy 阅读(70) 评论(0) 推荐(0) 编辑

hdu 1228

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1228题意:中文……mark:仔细。。代码:#include <stdio.h>#include <string.h>int tr(char a[]){ if(!strcmp(a, "zero")) return 0; if(!strcmp(a, "one")) return 1; if(!strcmp(a, "two")) return 2; if(!strcmp(a, "three")) retu 阅读全文

posted @ 2012-07-01 14:27 andre_joy 阅读(219) 评论(0) 推荐(0) 编辑

hdu 1425

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1425题意:中文……mark:qsor()简单水过。不过效率不是很高,985ms,可以用别的排序方法加快效率。代码:#include <stdio.h>#include <stdlib.h>int cmp(const void *a, const void *b){ return *(int *)b - *(int *)a;}int a[1000010];int main(){ int m,n,i; while(~scanf("%d%d", &n, & 阅读全文

posted @ 2012-07-01 14:04 andre_joy 阅读(275) 评论(0) 推荐(0) 编辑

hdu 2526

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2526题意:中文……下一行字符根据上一行对应三个字符来决定。mark:无。代码:#include <stdio.h>#include <string.h>char a[2][510],b[8][4];int f[8];int tr(char c[]){ int i; for(i = 0; i < 8; i++) if(!strcmp(c, b[i])) return f[i];}int main(){ char c[4]; int t,m,le; int i,... 阅读全文

posted @ 2012-07-01 13:57 andre_joy 阅读(164) 评论(0) 推荐(0) 编辑

hdu 1408

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1408题意:中文……mark:wa了一次。。主要是精度问题,要判断好究竟滴多少次。代码:#include <stdio.h>int main(){ double v,d; int i,sum,m; while(~scanf("%lf%lf", &v, &d)) { sum = 0; if((int(v/d))*10 == (int)(v/d*10)) m = (int)(v/d); else m = (int)(v/d) + 1; ... 阅读全文

posted @ 2012-07-01 01:19 andre_joy 阅读(76) 评论(0) 推荐(0) 编辑

hdu 2522

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2522题意:中文……mark:真是2死了,wa了5次。开始是因为数组开小了,因为余数是在n*10的范围内的,所以数组要开10^6。后来是因为给a[]初始化的时候,n应该先转换成正数,结果一直wa。。。此题是模仿除法运算,每一步输出一个结果。代码:#include <stdio.h>int a[1000010];int main(){ int t,n,m; scanf("%d", &t); while(t-- && scanf("%d&qu 阅读全文

posted @ 2012-07-01 00:46 andre_joy 阅读(146) 评论(0) 推荐(0) 编辑