上一页 1 ··· 33 34 35 36 37 38 39 40 41 ··· 52 下一页
摘要: 总是不能正确的将一个大问题变成子问题,而且又找不到状态转移方程。 直接导致这题想了5个小时最后还是无果。。。谨记!Number StringTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1136Accepted Submission(s): 503Problem DescriptionThe signature of a permutation is a string that is computed as follows: for eac 阅读全文
posted @ 2013-10-19 12:47 chenhuan001 阅读(288) 评论(0) 推荐(0) 编辑
摘要: 比赛的时候不知道怎么写。。。 太弱了。看了别人的代码,觉得这个是个经典的知识点吧。 gcd的巧妙运用自己想的时候苦苦思考怎么用dp求解。 无奈字符串太长而想不出好的算法。其实在把a和b字符串都分成以gcd(a,b)长度为单位的字符串时。 设为la=a/gcd(a,b) ,lb=b/gcd(a,b) . 明显可以知道的是gcd(la,lb)==1, 所以la与lb长度的字符串要分别拼接lb和la次才能拼成两个相等的串. 这样就有了解法. for(int i=0;i<lena;i++) dpa[i%k][a[i]-'a']++; // 统计在a串 在gcd(a,b)长度某一位 阅读全文
posted @ 2013-10-16 15:37 chenhuan001 阅读(477) 评论(0) 推荐(0) 编辑
摘要: 求N个数阶乘末尾除0后的数值。主要的难点在于要把这个N个数所含的2和5的队数去掉。网上方法很多很好。 不多说Last non-zero Digit in N!Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java... 阅读全文
posted @ 2013-10-09 13:28 chenhuan001 阅读(645) 评论(0) 推荐(0) 编辑
摘要: dp还是比较好想的,但是时间还是比较坑的。 要预处理还加些优化才行 。#include #include #include #include #include #include #include #include #include using namespace std;#define INF 0x3fffffff#define MOD 1000000007int n,m,k;int dp[101][1010][35];int save[1010][1010];int g[35];int cnt=0;int mark[1100];//bool mark1[1100][1100];int gcd 阅读全文
posted @ 2013-10-07 22:02 chenhuan001 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 这种思想很经典。 从最小的边选择,那么可以知道的是,在除去这条边的另外两个联通块,选其中一块中的点做为源点到另一块所得到的费用和。 如果你已经知道了这两个联通块内部选一个点时的最大费用和。那么这题就可以直接得到答案了,然后用递归思想独立的求这两块联通块。但是这样不好实现。 如果再反着想, 把边从大到小放入图中然后记录每个联通块的最大值。 然后就是合并的时候选择的问题了 。经典的思想,要好好记下 。#include #include #include #include #include #include #include #include #include using namespace std 阅读全文
posted @ 2013-10-07 08:57 chenhuan001 阅读(403) 评论(0) 推荐(0) 编辑
摘要: 注意题目的一个关键条件(a-1)2 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 using namespace std;11 #define INF 0x3fffffff12 13 typedef __int64 LL;14 15 LL a,b,n,m;16 LL g[2][2];17 LL MOD;18 19 void cal(LL s[2][2],LL t[2][2])20 {21 LL tmp[2][2];22 memse... 阅读全文
posted @ 2013-10-03 22:00 chenhuan001 阅读(335) 评论(0) 推荐(0) 编辑
摘要: int stk[N],vis[N],low[N],link[N],mark[N];int top,index,id,du[N];//记录入度数int pre[N],cnt,g[N];// g 用来记录topsort后的结果int g1[N]; //用来记录缩点后的每一个点所含的点void dfs(int s){ mark[s]=1; vis[s]=index++; low[s]=vis[s]; stk[top++]=s; for(int p=pre[s];p!=-1;p=edge[p].next) { int v=edge[p].to; ... 阅读全文
posted @ 2013-10-03 17:14 chenhuan001 阅读(351) 评论(0) 推荐(0) 编辑
摘要: 数位dp每次都给我一种繁琐的感觉。。A -Palindromic NumbersTime Limit:2000MSMemory Limit:32768KB64bit IO Format:%lld & %lluSubmitStatusDescriptionA palindromic number or numeral palindrome is a 'symmetrical' number like 16461 that remains the same when its digits are reversed. In this problem you will be g 阅读全文
posted @ 2013-10-03 12:10 chenhuan001 阅读(327) 评论(1) 推荐(0) 编辑
摘要: //还需加PI 和 mabs 函数double chg(double x,double y){ double tmps; if(mabs(x-0)0) tmps=90.0; else tmps=270.0; } else { tmps=y/x; //将这个点的斜率求出来 if(mabs(y-0)0) tmps=0.0; else tmps=180.0; } else { tmps=atan(tmps);//求出角度 ... 阅读全文
posted @ 2013-10-02 21:56 chenhuan001 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 枚举所有可能的半径,然后将所有满足这个半径的点按角度(与x轴正半轴的夹角)排序。 然后一遍扫描求出在这个半径下选k个点所需的最小面积 。思路还是比较简单,实现略有些繁琐。要先将点的坐标转换为角度。 如果用斜率的方法的话有些繁琐。Fire-Control SystemTime Limit: 12000/5000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2047Accepted Submission(s): 350Problem DescriptionA new mighty wea 阅读全文
posted @ 2013-10-02 21:49 chenhuan001 阅读(370) 评论(0) 推荐(0) 编辑
上一页 1 ··· 33 34 35 36 37 38 39 40 41 ··· 52 下一页