上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 15 下一页
摘要: 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1513最长公共子序列模版题。View Code 1 #include <cstdio> 2 #include<iostream> 3 #include<string.h> 4 using namespace std; 5 char cc[5001]; 6 int dp[2][5001]; 7 int n; 8 inline int Min(int x,int y) 9 {10 return x>y?y:x;11 }12 int main()13 {14 whi. 阅读全文
posted @ 2012-09-13 21:01 淡墨æ末央 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 链接:http://poj.org/problem?id=1845将A进行质因数分解,则A^B=(p1^k1)*(p2^k2)*...*(pn^kn)根据公式,所有因子之和为 (1+p1+p1^2+...p1^k1)*(1+p2+p2^2+...p2^k2)*...*(1+pn+pn^2+...+pn^kn) 计算1+p+p^2+...p^n可以利用二分进行加速 当n为奇数时 1+p+p^2+...p^n=(1+p+p^2+...+p^(k/2))*(1+p^(k/2+1)) 当n为偶数时 1+p+p^2+...p^n=(1+p+p^2+...+p^(k/2-1))*(1+p^(k/2+1)) 阅读全文
posted @ 2012-09-13 16:29 淡墨æ末央 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1172View Code 1 #include <cstdio> 2 #include <iostream> 3 #include <cmath> 4 #include <cstdlib> 5 #include <cstring> 6 #include <algorithm> 7 using namespace std; 8 typedef long long LL; 9 int s[110][3];10 int test( int 阅读全文
posted @ 2012-09-13 12:28 淡墨æ末央 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 链接:http://acm.hdu.edu.cn/showproblem.php?pid=3201思路: 周长一定, 圆的面积最大~View Code 1 #include <cmath> 2 #include <cstdio> 3 using namespace std; 4 const double PI = acos(-1.0); 5 int n; 6 int main() { 7 while (scanf("%d", &n) != EOF) { 8 if (n == 0) break; 9 printf("%... 阅读全文
posted @ 2012-09-12 17:51 淡墨æ末央 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 链接:http://poj.org/problem?id=1664View Code 1 #include <cstdio> 2 #include <cstdlib> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 using namespace std; 7 int dp[12][12]; 8 void fuck( ) 9 {10 dp[1][1]=1; 11 for( int i=2; i<12; ++ i ){12 dp[i][1]=dp[1 阅读全文
posted @ 2012-08-14 11:17 淡墨æ末央 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 链接:http://poj.org/problem?id=1014题意: 价值为 i 的物品分别有 a[i] 个, 问是否能够均分。多重背包问题。View Code 1 #include <cstdio> 2 #include <cstdlib> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 using namespace std; 7 int a[10], M, dp[100000]; 8 void zpack( int w, int v ) 9 { 阅读全文
posted @ 2012-08-12 10:14 淡墨æ末央 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 链接:http://poj.org/problem?id=1023View Code 1 #include <cstdio> 2 #include <cstdlib> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 using namespace std; 7 typedef long long LL; 8 int T, N; 9 LL M;10 char s[100];11 int t[100];12 int main( )13 {14 scanf( 阅读全文
posted @ 2012-08-11 09:33 淡墨æ末央 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 一些基本概念定义1.设a,b是整数,b≠0.如果有一个整数c,它使得a=bc,则a叫做b的倍数,b叫做a的因数。我们有时说,b能整除a戒者a能被b整除如果b能整除a,我们就用b|a这个符号来表示它,例如2|4,3|6,-5|20整除的性质:(1)若a|b,b|c,则a|c;(2)若a|b,那么对所有整数c,a|bc;(3)若c|a且c|b,则c|(ma+nb)(m,n为整数);(4)若b|a且a!=0,则|b|<=|a|;(5)若cb|ca,则b|a;定义2.一个大亍1的正整数,只能被1和它本身整除,丌能被其他正整数整除,这样的正整数叫做素数(也叫质数)定义3.如果一个正整数a有一个因数 阅读全文
posted @ 2012-08-08 14:56 淡墨æ末央 阅读(256) 评论(0) 推荐(0) 编辑
摘要: http://hi.baidu.com/aekdycoin/item/e493adc9a7c0870bad092fd9 阅读全文
posted @ 2012-08-03 15:55 淡墨æ末央 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 链接http://acm.hdu.edu.cn/showproblem.php?pid=4324此题可以一遍拓扑排序判环求解 即只需要找到一个环,就必定存在三元环 证明如下: 假设存在一个n元环,因为a->b有边,b->a必定没边,反之也成立 所以假设有环上三个相邻的点a-> b-> c,那么如果c->a间有边,就已经形成了一个三元环,如果c->a没边,那么a->c肯定有边,这样就形成了一个n-1元环。。。。 所以只需证明n为4时一定有三元环即可,显然成立。View Code 1 #include <stdio.h> 2 #include 阅读全文
posted @ 2012-08-02 09:44 淡墨æ末央 阅读(196) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 15 下一页