上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 21 下一页
摘要: http://poj.org/problem?id=2115题意:给出A,B,C和k(k表示变量是在k位机下的无符号整数),判断循环次数,不能终止输出"FOREVER".即转化成 c*x = b-a mod (2^k), 解这个模线性方程的最小正整数解。模板题,代码很短,但是很难理解的样子。。。转载了一些有关的资料。。。 1 #include 2 #define LL long long 3 4 LL Extend_Euclid(LL a,LL b,LL & x,LL & y)//扩展欧几里得 5 { 6 if (!b) 7 { 8 x = 1; 9 ... 阅读全文
posted @ 2013-10-08 20:25 N_ll 阅读(247) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=1260 1 #include 2 #include 3 #include 4 5 using namespace std; 6 int main() 7 { 8 int t,dp[120],s[120]; 9 cin>>t;10 while(t--)11 {12 int n,ai[120],pi[120];13 cin>>n;14 s[0] = 0;15 for (int i = 1; i >ai[i]>>pi[i];18 ... 阅读全文
posted @ 2013-10-07 14:30 N_ll 阅读(193) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=3267题意:给出一个主串,一些单词,匹配这些单词,问至少要删除多少字符。 1 #include 2 #include 3 #include 4 #include 5 #include 6 int dp[350];//dp[i]表示i->L删除的字符数 7 using namespace std; 8 int main() 9 {10 int n,L;11 string word[606],s;12 cin>>n>>L;13 cin>>s;14 for (int i = 0; i >word[. 阅读全文
posted @ 2013-10-07 11:10 N_ll 阅读(187) 评论(0) 推荐(0)
摘要: B. Jeff and Periodstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Jeff got hold of an integer sequence a1, a2, ..., an of length n. The boy immediately decided to analyze the sequence. For that, he needs to find all values of x, for which 阅读全文
posted @ 2013-10-05 16:35 N_ll 阅读(302) 评论(0) 推荐(0)
摘要: A. Jeff and Digitstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputJeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible 阅读全文
posted @ 2013-10-05 11:42 N_ll 阅读(205) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=1159题意:给定一个字符,问最少插入多少字符,使该字符串变成回文字符串。思路:设原字符串序列为X,其逆字符串为Y,则最少插入的字符数=length(X)-X与Y的最长公共子序列的长度。求LCS的状态转移方程为 max(dp[i-1][j],dp[i][j-1]) s1[i-1]!=s2[j-1] dp[i][j] = dp[i-1][j-1]+1; s1[i-1]==s2[j-1];由于数据范围大,本题使用的滚动数组。 1 #include 2 #... 阅读全文
posted @ 2013-09-28 20:08 N_ll 阅读(141) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=1837 1 #include 2 #include 3 const int N=15002; 4 int dp[21][N]; 5 int main() 6 { 7 int n,num; 8 int dis[21],w[21]; 9 memset(dp,0,sizeof(dp));10 scanf("%d%d",&n,&num);// n钩子数,num砝码数11 for (int i = 1; i <= n; i ++)12 scanf("%d",&dis[i]);13 阅读全文
posted @ 2013-09-19 10:53 N_ll 阅读(177) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4712题意:计算任意两个十六进制的数异或后1的最少个数。思路:用随机数随机产生两个数作为下标,记录这两个数异或后1的个数,输出1的个数最少是多少。 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 const int N=100002; 8 const int INF=1<<29; 9 int f[N];10 int main()11 {12 int t;13 scanf("%d",&a 阅读全文
posted @ 2013-09-13 17:13 N_ll 阅读(196) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4715题意:给一个偶数,将这个偶数用两个最小的素数表示,如果不能表示则输出FALL; 注意给定的偶数可能为负值。思路:素数打表,将给定的数从第一个素数开始相加,判断相加后的值是否为素数。 1 #include 2 #include 3 4 const int N=1000050; 5 int f[N],p[N/2]; 6 int num;//1e6内素数个数 7 8 void is_prime() 9 {10 f[1] = 0;11 f[2] = 1;12 for (int i... 阅读全文
posted @ 2013-09-13 16:10 N_ll 阅读(244) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4707题意:判断距离大于D的点有多少个。思路: 邻接表建图,dfs每一个点,记录步数。 1 #include 2 #include 3 const int N=200002; 4 int vis[N],dis[N],head[N],cnt,step; 5 struct node 6 { 7 int u; 8 int v; 9 int next;10 } edge[N];11 void add(int u,int v)12 {13 edge[cnt].u = u;14 ... 阅读全文
posted @ 2013-09-13 13:57 N_ll 阅读(159) 评论(0) 推荐(0)
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 21 下一页