随笔分类 -  HDOJ

上一页 1 2 3 4 5 6 7 8 9 ··· 24 下一页

发布一些HDOJ的做题情况以及代码。
hdu 2550
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=2550题意:中文。mark:2wa,没看清题意,还要按箭身长度排序,囧。代码:# include <stdio.h># include <stdlib.h>typedef struct NODE{ int a, b ;}NODE ;NODE num[100] ;int cmp(const void *a, const void *b){ NODE *p = (NODE*)a, *q = (NODE*)b ; return p->a - q->a ;}void outp 阅读全文

posted @ 2012-02-19 08:12 Seraph2012 阅读(171) 评论(0) 推荐(0)

hdu 2549
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=2549题意:中文。mark:水题不解释。代码:# include <stdio.h># include <string.h>int main (){ int T ; int a, n, len ; char str[10] ; scanf ("%d", &T) ; while (T--) { scanf ("%d.%s %d", &a, str, &n) ; len = strlen(str) ; if (n < 阅读全文

posted @ 2012-02-19 07:55 Seraph2012 阅读(248) 评论(9) 推荐(0)

hdu 2548
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=2548题意:中文。mark:著名的ooxx题。。。不解释。代码:# include <stdio.h># include <math.h>int main (){ int T ; double a, b, c, d ; scanf ("%d", &T) ; while (T--) { scanf ("%lf%lf%lf%lf", &a, &b, &c, &d) ; printf ("%.3l 阅读全文

posted @ 2012-02-19 07:51 Seraph2012 阅读(140) 评论(0) 推荐(0)

hdu 2547
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=2547题意:中文。mark:其实就是求两点间距离,水。注意输入数据是实数。代码:# include <stdio.h># include <math.h>int main (){ int T ; double a, b, c, d ; scanf ("%d", &T) ; while (T--) { scanf ("%lf%lf%lf%lf", &a, &b, &c, &d) ; printf (&q 阅读全文

posted @ 2012-02-19 07:49 Seraph2012 阅读(208) 评论(0) 推荐(0)

hdu 1722
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1722题意:中文。mark:公式,p+q-gcd(p,q)。证明不懂。。。见大牛博客。http://blog.sina.com.cn/s/blog_696187fd0100soe2.html代码:# include <stdio.h>int gcd(int p, int q){return p%q?gcd(q,p%q):q;}int main (){ int p, q ; while (~scanf ("%d%d", &p, &q)) printf (&q 阅读全文

posted @ 2012-02-19 07:45 Seraph2012 阅读(173) 评论(0) 推荐(0)

hdu 1323
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1323题意:某数的真因子加起来比它大叫做ABUNDANT,比它小叫做DEFICIENT,相等叫做PERFECT。输入一个数,输出它是哪种情况。直接暴。代码:# include <stdio.h>int main (){ int n, ans, i ; puts ("PERFECTION OUTPUT") ; while (~scanf ("%d", &n),n) { for(i = 1,ans=0 ; i < n && a 阅读全文

posted @ 2012-02-16 10:27 Seraph2012 阅读(154) 评论(0) 推荐(0)

hdu 1328
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1328题意:输入一个字符串,没个字符后移1位后输出。代码:# include <stdio.h>int main (){ int T, i, nCase = 1 ; char str[55] ; scanf ("%d", &T) ; while (T--) { scanf ("%s", str) ; for(i = 0 ; str[i] ; i++) str[i] = (str[i]-'A'+1)%26+'A' 阅读全文

posted @ 2012-02-16 10:08 Seraph2012 阅读(148) 评论(0) 推荐(0)

hdu 1334
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1334题意:输出所有(1,200]区间上满足a^3==b^3+c^3+d^3的式子。mark:水题,枚举a、b、c,在[c,a-1]区间上二分求d后验证。n次wa,二分写得挫。代码:# include <stdio.h># include <math.h>int sqrt3(int num,int l,int r){ int mid = 210 ; if (l*l*l>num) return 0 ; if (r*r*r<num) return 210 ; while 阅读全文

posted @ 2012-02-16 10:01 Seraph2012 阅读(269) 评论(0) 推荐(0)

hdu 2374
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=2374题意:有n个碗,标号为1到n。每个碗内有一些小珠子。每次从一个碗里拿出一个珠子,此时要往所有编号小于它的碗内各放入一颗珠子。问要拿多少次才能把所有的珠子拿完。mark:直接模拟。没注意I64d,1wa。代码:# include <stdio.h>long long num[60] ;int main (){ int i, j, n ; long long rtn ; while (~scanf ("%d", &n),n) { rtn = 0 ; ... 阅读全文

posted @ 2012-02-16 08:48 Seraph2012 阅读(203) 评论(0) 推荐(0)

hdu 1335
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1335题意:前面是一个7位a进制数,表示成后面的进制。如果超过7位则输出ERROR。直接模拟。代码:# include <stdio.h>char str[40] ;int chartonum(char ch){ if (ch >= '0' && ch <= '9') return ch-'0' ; return ch-'A'+10 ;}int gao(char str[], int b){ int 阅读全文

posted @ 2012-02-16 08:34 Seraph2012 阅读(163) 评论(0) 推荐(0)

hdu 2370
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=2370题意:一个数字可以表示成若干个fibonacci数的和。求表示成fib后“右移”1位的数字。mark:打表前30个fib数,然后用贪心法可算出任何数字的fib数表示形式,再累加。代码:# include <stdio.h># include <string.h>int fib[35] = {1,1} ;int tab[35] ;void init(){ int i ; for (i = 2 ; i <= 30 ; i++) fib[i] = fib[i-1]+fib[ 阅读全文

posted @ 2012-02-16 08:15 Seraph2012 阅读(191) 评论(0) 推荐(0)

hdu 1342
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1342题意:从给定的集合里面选出6个数字按顺序输出。把所有的选择都输出。mark:直接dfs就好了。代码:# include <stdio.h>int k ;int num[20] ;int ans[6] ;void dfs(int idx, int n){ int i ; if (n == 6) { for(i = 0 ; i < n ; i++) if (i == 0) printf("%d",ans[i]) ; else ... 阅读全文

posted @ 2012-02-16 07:33 Seraph2012 阅读(174) 评论(0) 推荐(0)

hdu 1361
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1361题意:对于一个合法的括号序列S,可以计算出P和W的值。P的第i个值表示第i个右括号前面有多少个左括号,W的第i个值表示第i个右括号会和前面第几个左括号匹配。现在给出P的值,求W的值。mark:因为数据很小,n的长度只有20,因此可以直接模拟,由P反求出S,然后由S直接求出P。代码:# include <stdio.h># include <string.h>char str[50] ;int p[50],w[50] ;int n ;void setstr(){ int nu 阅读全文

posted @ 2012-02-16 07:21 Seraph2012 阅读(184) 评论(0) 推荐(0)

hdu 1715
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1715题意:算fibonacci数。mark:大数运算。第1000个fib数只有200多位,直接打表好了。代码:# include <stdio.h>int fib[1010][300] ;char str[300] ;void add(int a[], int b[], int c[]){ int *p, *q ; int i, cc = 0 ; if(a[0]<b[0])p=a, q=b ; else p = b, q=a ; for(i = 1 ; i<= q[0] ... 阅读全文

posted @ 2012-02-16 06:52 Seraph2012 阅读(200) 评论(0) 推荐(0)

hdu 1370
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1370题意:有3个循环周期,周期天数分别为23、28、33。对于某一年,已知某年这3个周期的某一峰值分别是当年的第p、e、i天,问从第d天开始到最近一个满足3个周期都达到峰值的日期还有多少天。mark:据说是剩余定理。数据比较小,直接打表可过。比较蛋疼的是wa了很多次,因为算减法以后忘记取模了。。。代码:# include <stdio.h>int tab[40][40][40] ;int _0(int num){ if (num <= 0) return num + 21252 ; 阅读全文

posted @ 2012-02-16 06:42 Seraph2012 阅读(301) 评论(0) 推荐(0)

hdu 1379
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1379题意:输入一堆字符串,按“逆序数值”排序。如果相同,按输入顺序。mark:50个字符串,每个长度是100,算逆序数是O(n^2),复杂度是500000,直接暴力可搞。数据比较水,排序直接用qsort不用考虑输入顺序。如果非要考虑也可以,加一个下标表示原来的序号,比较的时候多比较一下就OK了。代码:# include <stdio.h># include <stdlib.h>typedef struct STRING{ char str[110] ; int unsorted 阅读全文

posted @ 2012-02-16 04:12 Seraph2012 阅读(173) 评论(0) 推荐(0)

hdu 1720
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1720题意:输入十六进制的a和b,输出十进制的a+b。代码:main(a,b){while(~scanf("%x%x",&a,&b))printf("%d\n",a+b);} 阅读全文

posted @ 2012-02-15 19:47 Seraph2012 阅读(120) 评论(0) 推荐(0)

hdu 1393
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1393题意:一个钟面只有一根分针。对于一个数字d,把中面上的分针指向的时间s往后拨s的d倍。问给定d,重复这样的操作多少次能回拨到0。若不能则输出Impossible。mark:因为钟面只有60分钟,所以最多不会超过60次,直接暴力就可。代码:# include <stdio.h>int main (){ int i, s, d, cnt ; int tab[100] ; while (~scanf ("%d%d", &s, &d) && 阅读全文

posted @ 2012-02-15 19:09 Seraph2012 阅读(175) 评论(0) 推荐(0)

hdu 1395
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1395题意:给出n,求满足2^x mod n = 1的最小的x。mark:数论题,其实就是求a模m的阶。打素数表敲错变量,1wa。可以水过,但是最好需要知道以下知识。1. 若gcd(a,m)==1,一定存在一个正整数d<m使得a^d == 1 mod m(欧拉定理)。2. 满足条件的最小正整数d记为ord_m(a),叫做a模m的阶。3. 若对于一个正整数a满足(1)gcd(a,m)==1;(2)ord_m(a)==φ(m)(φ(m)表示m的欧拉函数);则a叫做m的一个原根。4. 若gcd(a,m) 阅读全文

posted @ 2012-02-15 06:49 Seraph2012 阅读(572) 评论(0) 推荐(0)

hdu 1564
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1564题意:从一个n*n的棋盘的某个角落开始,走过的格子不能再走,每次轮流移动棋子(上下左右),最后无法移动的人输。问是否有先手必胜的策略。mark:打表后看出规律。证明不会。代码:main(n){while(scanf("%d",&n),n)puts(n&1?"ailyanlu":"8600");}打表程序:# include <stdio.h>int n ;int graph[1010][1010] ;int d 阅读全文

posted @ 2012-02-15 00:52 Seraph2012 阅读(470) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 9 ··· 24 下一页