摘要: 1206. Stacking CylindersConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionProblem Cylinders (e.g. oil drums) (of radius 1 foot) are stacked in a rectangular bin. Each cylinder on an upper row rests on two cylinders in the row below. The cylinders in the bottom row rest on the floor and do 阅读全文
posted @ 2013-12-10 15:01 y丫t 阅读(572) 评论(0) 推荐(0)
摘要: DP 水题PermutationConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionPermutation plays a very important role in Combinatorics.For example, 1 2 3 4 5 and 1 3 5 4 2 are both 5-permutations.As everyone's known, the number of n-permutations is n!.According to their magnitude relatives, if we 阅读全文
posted @ 2013-12-09 18:35 y丫t 阅读(367) 评论(0) 推荐(0)
摘要: DescriptionIn the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. For example, the first ten terms of the Fibonacci sequence are:0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …Given two integers n and m, your goal is to compute the value of Fn mod m. InputThe input test file will 阅读全文
posted @ 2013-12-05 21:09 y丫t 阅读(298) 评论(0) 推荐(0)
摘要: #include#includeint mon,num;int dp[30001],x[26],y[26];int main(){ scanf("%d%d",&mon,&num); memset(dp,0,sizeof(int)); for(int i=0;i=x[i];--j) //剪支,之前我是从1开始枚举的T~T。。 if(dp[j-x[i]]+y[i]*x[i] > dp[j]) dp[j] = dp[j-x[i]]+y[i]*x[i]; printf("%d",dp[mon]); return 0;} 阅读全文
posted @ 2013-11-25 16:31 y丫t 阅读(137) 评论(0) 推荐(0)
摘要: 01背包(j=max;j>mon;--j): 开心的金明 , 采药(++)乌龟棋,sicily1538? (壁虎吃蚊子那道题)最长回文串类型 sicily 1001 阅读全文
posted @ 2013-11-25 16:29 y丫t 阅读(115) 评论(0) 推荐(0)
摘要: http://soj.me/show_problem.php?pid=1563明显的水题,几分钟敲出来;测试下样例,居然发现答案不一样。。鉴于上次乌龟棋数组开太小,数据是long的,虽然目测这题数据还行,还是改成long了。。int 我估计也行。。目测纠结一番,不知道哪里错了。输出每次 cur[][] 的变化,更加郁闷,有最大值32啊,为什么我输出26呢。。输出答案,更加郁闷;我就不信是人品技术问题。。再瞄~~26是最后一行的。。。WA!!我倒,要输出 ans 的,居然打成cur[][];AC了。。。大清早的拿道题清醒下。居然发生这种事情,T~T...。 06.#include07.#incl 阅读全文
posted @ 2013-11-25 09:58 y丫t 阅读(211) 评论(0) 推荐(0)
摘要: 递归类型大致方向有两种,第一是数值计算的(兔子数列)(可以用矩阵加快速幂优化),第二是文字非纯数据的(汗诺塔)递归时。,只需考虑一步和周期间的(打 × 处)(1 2 3 1 2 3) × × ×#includeint n;void hanoi(int n,char a,char b,char c){ if(n==1) printf("%d from %c to %c\n",n,a,c); else { hanoi(n-1,a,c,b); //把n-1个盘移到B中后 printf("%d from %c to %c\n&quo 阅读全文
posted @ 2013-11-22 18:41 y丫t 阅读(189) 评论(0) 推荐(0)
摘要: 1. 编程入门2. 数据结构3. 字符串4. 排序5. 图遍历6. 图算法7. 搜索:剪枝,启发式搜索8. 动态规划/递推9. 分治/递归10. 贪心11. 模拟12. 算术与代数13. 组合问题14. 数论15. 网格,几何,计算几何【编程入门】PC 110101, uva 100, The 3n+1 problem, 难度 1 PC 110102, uva 10189, Minesweeper, 难度 1 PC 110103, uva 10137, The Trip, 难度 1 pc 110104, uva 706, LC-Display, 难度 1pc 110105, uva 10267 阅读全文
posted @ 2013-11-17 13:56 y丫t 阅读(931) 评论(0) 推荐(0)
摘要: #include#includeusing namespace std;bool flag;string s1,s2,s;void dp(int len1,int len2,int len){ if(flag) return; if(len==-1) {flag=1;return;} if((len1>=0) && (s1[len1]==s[len])) dp(len1-1,len2,len-1); if((len2>=0) && (s2[len2]==s[len])) dp(len1,len2-1,len-1); ... 阅读全文
posted @ 2013-11-17 11:20 y丫t 阅读(198) 评论(0) 推荐(0)
摘要: _gXX遇到一个麻烦的式子:S = n1+ n2+ n3+ ...... + nk,已知n、k,求S的值。因为_gXX数学很差,希望你能告诉他答案。但是由于他的数学实在太差了,所以你只需要告诉他S除以9901的余数即可。 Input两个整数,n和k(n ≤ 1000 , k ≤ 109)。 Output一个数,表示S除以9901的余数。 Sample Input2 3 Sample Output14// 费马小定理,若a为整数,p为质数,则a^{p-1} \equiv 1 \pmod{p} , 即循环等于1,9901为素数,因此只需计算k模9900个数的和的模。// 1*n (1+n)*n ( 阅读全文
posted @ 2013-11-14 20:41 y丫t 阅读(205) 评论(0) 推荐(0)