随笔分类 -  HDOJ

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

发布一些HDOJ的做题情况以及代码。
hdu 2068
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=2068题意:中文。mark:如果知道错排公式就很简单了。wa了一次。。。<=写成了<。。。PE一次。莫名其妙多加了个空格。sb了。代码:# include <stdio.h>long long c[30][30] = {1} ;long long cp[15] = {0, 0, 1} ;void init(){ int i, j ; for (i = 1 ; i <= 25 ; i++) { c[i][0] = 1 ; for (j = 1 ; j <= i... 阅读全文

posted @ 2012-01-13 07:08 Seraph2012 阅读(232) 评论(0) 推荐(0)

hdu 1420
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1420题意:求a^b mod c。mark:快速幂无疑是最简单的写法。不过c只有100w,也可以用数论的方法做。此处用的是快速幂。代码:# include <stdio.h>int mod ;int qpow(long long a, long long b){ long long ans = 1, buff = a ; while (b) { if (b&1) ans = (ans*buff) % mod ; b >>= 1 ; buff =... 阅读全文

posted @ 2012-01-13 06:39 Seraph2012 阅读(172) 评论(0) 推荐(0)

hdu 1072
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1072题意:I想(从2处)逃出迷宫(3处),0是墙,1是空地。身上有定时炸弹,在第6s爆炸(只能走5步)。4处是将定时炸弹重设的工具。问它最快能否逃出迷宫。mark:bfs。多添加一个数组标记上次到达当前位置时定时炸弹的剩余秒数。代码:# include <stdio.h># include <string.h>int n, m ;int graph[10][10] ;int step[10][10] ;int times[10][10] ;int sx, sy, ex, ey 阅读全文

posted @ 2012-01-13 06:34 Seraph2012 阅读(195) 评论(0) 推荐(0)

hdu 1593
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1593题意:中文。mark:1wa。直接往开始的反方向按半径逃不可以。找一个同心圆,让V1的角速度略大V2。在那个圈上0086可以甩对方一个直径后再往岸边划。代码:# include <stdio.h># include <math.h># define Pi acos(-1)int main (){ int R, V1, V2 ; double t1, t2 ; while (~scanf ("%d%d%d", &R, &V1, &V 阅读全文

posted @ 2012-01-13 03:47 Seraph2012 阅读(166) 评论(0) 推荐(0)

hdu 1231
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1231题意:中文。最大连续子川和。经典dp(不知道算不算dp)。代码:# include <stdio.h>int a[10010] ;int n, s, e, max_sum ;void find(){ int i, ss = s, ee = e, sum = max_sum ; for (i = 1 ; i < n ; i++) { if (sum < 0) ss = ee = sum = a[i] ; else { ... 阅读全文

posted @ 2012-01-13 02:46 Seraph2012 阅读(167) 评论(0) 推荐(0)

hdu 1898
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1898题意:S和X比做题。他们的做题顺序是一样的,但并不是做一题交一题。S每A分钟交一次,X每B分钟交一次。问T分钟的时候是谁交的题多。mark:水。假设每分钟做1题,求出两人各自交了多少题后比较。。。代码:# include <stdio.h>int main (){ int T ; int a, b, t, aa, bb ; scanf ("%d", &T) ; while (T--) { scanf ("%d%d%d", &a, 阅读全文

posted @ 2012-01-13 01:50 Seraph2012 阅读(146) 评论(0) 推荐(0)

hdu 1718
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1718题意:问给定学号在所有成绩里的排名。。。mark:无聊题。1wa,多组输入。。。代码:# include <stdio.h>int a[1100], b[1100] ;int main (){ int i, aa, ans, cnt = 0 ; while (~scanf ("%d", &aa)) { cnt = 0 ; while (~scanf ("%d%d", &a[cnt], &b[cnt])) { if (... 阅读全文

posted @ 2012-01-11 22:42 Seraph2012 阅读(135) 评论(0) 推荐(0)

hdu 1286
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1286题意:中文。mark:看似很绕其实就是求欧拉函数Phi(n)。对于所有n的素因子Pi,欧拉函数Phi(n) = n * (P1-1)/P1 * (P2-1)/P2 * (P3-1)/P3 ...。对于每一个Pi,因为n总是Pi的倍数,所以可以先除再乘,不会溢出。代码:# include <stdio.h>int Primes[40000] = {2, 3} ;int PrimeNum = 2 ;int dp[40000] ;int calc(int nn){ int ans = nn, 阅读全文

posted @ 2012-01-11 01:21 Seraph2012 阅读(165) 评论(0) 推荐(0)

hdu 1563
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1563题意:找n个数里只出现了1次的数。mark:hash搞之。大于200的最小素数是211。代码:# include <stdio.h># include <string.h>int dp[211][2] ;void insert (int n){ int idx = n % 211 ; while (dp[idx][0] != n && dp[idx][1] != 0) idx++ ; dp[idx][0] = n ; dp[idx][1] ++ ;}int 阅读全文

posted @ 2012-01-08 05:25 Seraph2012 阅读(148) 评论(0) 推荐(0)

hdu 1491
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1491题意:给一个2006年的日期,问和2006年10月21日还差几天。mark:getdays是用于获得m月d日是当年的第几天。最后和10月21日做比较。代码:# include <stdio.h>int getdays (int m, int d){ int i, rtn = 0, month [12] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30} ; for (i = 0 ; i < m ; i++) rtn += m... 阅读全文

posted @ 2012-01-08 05:11 Seraph2012 阅读(217) 评论(0) 推荐(0)

hdu 1253
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1253题意:中文。。。mark:三维BFS水过。其实和二维没多大区别。代码:# include <stdio.h># include <string.h># define REP(i,a) for(i = 0 ; i < a ; i++)int q[55*55*55][3] ;int graph[55][55][55] ;int step[55][55][55] ;int a, b, c, t ;int tab[6][3] = {{0, 0, 1}, {0, 0, -1}, 阅读全文

posted @ 2012-01-08 01:09 Seraph2012 阅读(227) 评论(0) 推荐(0)

hdu 1577
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1577题意:中文。mark:gcd是否为1。注意不能有除数为0。代码:# include <stdio.h>int abs(int n){return n<0?-n:n;}int gcd(int a, int b){return a%b==0?b:gcd(b,a%b);}int main (){ int l, px, py, sx, sy ; while (~scanf ("%d", &l), l) { scanf ("%d%d%d%d" 阅读全文

posted @ 2012-01-08 00:11 Seraph2012 阅读(198) 评论(0) 推荐(0)

hdu 1708
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1708题意:给两个字符串s0和s1,sn是sn-1和sn-2拼接而成的。问sn中每个字母出现的次数。mark:直接递推就可以了。注意0的情况。代码:# include <stdio.h># include <stdlib.h># include <string.h>int t1[30], t2[30], t3[30] ;void output (int t[]){ int i ; for (i = 0 ; i < 26 ; i++) printf (" 阅读全文

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

hdu 2309
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=2309题意:给n个数,去掉一个最大的和一个最小的,然后求平均数。蛋疼的日式英文。代码:# include <stdio.h>int main (){ int n, max_n, min_n, num, sum ; int i ; while (~scanf ("%d", &n), n) { sum = 0 ; min_n = 1100, max_n = -1 ; for (i = 0 ; i < n ; i++) { ... 阅读全文

posted @ 2012-01-07 00:38 Seraph2012 阅读(159) 评论(0) 推荐(0)

[恢]hdu 2401
摘要:2012-01-02 19:55:02地址:http://acm.hdu.edu.cn/showproblem.php?pid=2401题意:有1-N一共N个篮子,每个里面有很多金币。每个金币的重量是w,但是其中有一个篮子金币的重量只有w-d。现在从第一个篮子拿1个金币,第二个拿2个。。。第n-1个篮子拿n-1个。第n个不拿。把拿出来的金币称重。问金币轻的篮子编号是多少。mark:不知道第二组sample为什么可以是10。。。诡异。代码:# include <stdio.h>int main (){ int n, w, d, rst, ans ; while (~scanf (&q 阅读全文

posted @ 2012-01-07 00:37 Seraph2012 阅读(183) 评论(0) 推荐(0)

[恢]hdu 2529
摘要:2012-01-02 17:22:53地址:http://acm.hdu.edu.cn/showproblem.php?pid=2529题意:中文。mark:设v的水平分量为x,则最终距离和x的关系应该是先增后减,遂三分。。。代码:# include <stdio.h># include <math.h>double l, v ;double f(double x){ return sqrt(v*v-x*x)*l/x - 0.5*9.8*l*l/(x*x) ;}int main (){ double left, right, m1, m2, h ; while (~sc 阅读全文

posted @ 2012-01-07 00:36 Seraph2012 阅读(159) 评论(0) 推荐(0)

[恢]hdu 2516
摘要:2012-01-02 04:07:41地址:http://acm.hdu.edu.cn/showproblem.php?pid=2516题意:中文。mark:完全不会。看了网上说打表看出规律似乎是Fibonacci。遂写代码。wa了一次,因为[0...43]的数量我用二分的时候居然算成了43个。。。应该是44个的。代码:# include <stdio.h># include <stdlib.h>int dp[50] = {2, 3} ;int cmp(const void *a, const void *b){ return *(int*)a - *(int*)b ; 阅读全文

posted @ 2012-01-07 00:35 Seraph2012 阅读(140) 评论(0) 推荐(0)

[恢]hdu 2512
摘要:2011-12-31 20:47:45地址:http://acm.hdu.edu.cn/showproblem.php?pid=2512题意:中文。。。mark:递推。dp[i][j]表示i张卡片分在j本书的种类数,有dp[i][j] = dp[i-1][j-1] + dp[i-1][j]*j。代码:# include <stdio.h># define MOD 1000int dp[2010][2010] ;int ans[2010] = {0, 1} ;int main (){ int T, n ; int i, j ; dp[1][1] = 1 ; for (i ... 阅读全文

posted @ 2012-01-07 00:34 Seraph2012 阅读(144) 评论(0) 推荐(0)

[恢]hdu 2539
摘要:2011-12-31 19:37:25地址:http://acm.hdu.edu.cn/showproblem.php?pid=2539题意:中文。有点点麻烦的模拟。代码:# include <stdio.h># include <string.h>char str[110] ;int goal[20] ;int judge (char s[]){ int len = strlen(s) ; if (len < 10) return 1 ; if (s[len-8] == ' ' && s[len-7] == 'n' 阅读全文

posted @ 2012-01-07 00:33 Seraph2012 阅读(127) 评论(0) 推荐(0)

[恢]hdu 2511
摘要:2011-12-31 20:09:16地址:http://acm.hdu.edu.cn/showproblem.php?pid=2511题意:中文。mark:递归。代码:# include <stdio.h>void gao(long long n, long long time, int s, int e){ int m = 6-s-e ; long long mid = (1LL<<(n-1)) ; if (time == mid) { printf ("%I64d %d %d\n", n, s, e) ; return ; } ... 阅读全文

posted @ 2012-01-07 00:33 Seraph2012 阅读(218) 评论(0) 推荐(0)

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