随笔分类 -  sicily UVA CF等题

摘要:给出Fibonacci的第i项和第j项。求第n项。InputThe input contains five integers in the following order:i,Fi,j,Fj,n.−1000 ≤i,j,n≤ 1000,i≠j,−2·109≤Fk≤ 2·109(k=min(i,j,n)... 阅读全文
posted @ 2015-10-15 13:04 y丫t 阅读(193) 评论(0) 推荐(0)
摘要:因为是图论专题,所以最初想到的是最短路,但是图怎么存?图的最短路需要保存可以经过的点(n*m个点10^6),肯定爆了,不可能只保存交叉点。果断放弃。考虑用DP 设当前在(i+1,j+1)表示到达这个点的最短距离。可以到达这里的点有三个。则(i+1,j+1)=min( (i+1,j)+1,(i,j+1... 阅读全文
posted @ 2015-08-23 16:47 y丫t 阅读(379) 评论(0) 推荐(0)
摘要:朴素DFS计算有多少个水坑TEST10 12W........WW..WWW.....WWW....WW...WW..........WW..........W....W......W...W.W.....WW.W.W.W.....W..W.W......W...W.......W.3 /* DF... 阅读全文
posted @ 2015-02-02 19:31 y丫t 阅读(142) 评论(0) 推荐(0)
摘要:1、暴搜 每只蚂蚁朝向有两种,可以枚举n只蚂蚁的朝向,然后模拟蚂蚁相遇的情景,总共2^n中情况。2、分析ants相碰的情况: (a->) () 由于每只蚂蚁是相同的,所以等价与(),这和两只蚂蚁原来的走向是一样的,即把碰撞当作没发生过 ... 阅读全文
posted @ 2015-02-02 19:05 y丫t 阅读(203) 评论(0) 推荐(0)
摘要:http://hihocoder.com/problemset/problem/1114这道题,扫雷,两行,给出第二行全部的地雷数目,让我们猜测第一行。思路: 考虑扫雷第二行数字的意义,(已知)[2][i]=[1][i-1]+[1][i]+[1][i+1] 第二行是从1开始的,我们将第一行第[0... 阅读全文
posted @ 2015-02-02 00:52 y丫t 阅读(268) 评论(0) 推荐(0)
摘要:刚拿到书,巫泽庆译,第二版,这两道题是入门的两道,准备吃饭,走在路上想能不能。。题1、有放回抽取小球,箱子有n个球,均写有数字,问抽四次能否抽到和为m,n个球上的数字给出。Sample Input : n=3,m=10,k={1,3,5}Ouput : Yes (1,1,3,5)很简单的枚举,用四个... 阅读全文
posted @ 2015-01-30 16:26 y丫t 阅读(744) 评论(1) 推荐(0)
摘要:题目:http://www.wikioi.com/problem/1044/int v[21],f[21];int ans;int main(){int n=0,x;while(scanf("%d",&x)==1) v[++n]=x;/*///////////////////////////////... 阅读全文
posted @ 2014-07-23 05:27 y丫t 阅读(236) 评论(0) 推荐(0)
摘要:状态转移方程可以直接用dp[i][j]=max(dp[i+1,j]+a[i],dp[i,j-1]+a[j])*(2^k)),但是还要算2^k次方,可以先用数组储存2的方幂,但不可避免高精度乘法,如果只是*2的话可以用加法代替逆向思考,自内而外,用f[i,j]表示从i取到j的最大值,状态转移方程便为f... 阅读全文
posted @ 2014-07-23 05:18 y丫t 阅读(262) 评论(0) 推荐(0)
摘要:初学者,从很基础的开始写。 我连二叉树都不是很熟悉就对这道题目感兴趣。适合初学者。 首先是想到动归。 参考别人的代码看到有二叉搜索树,上百科学习(有完整的讲解)。 讲讲我的想法: 1.当前区间的值=[i]+[i+1]...+[j]=sum[j]-sum[i]; 2.二元是比较麻烦的,故先固定一个,比如说j,然后寻到最大的sum[i]就是[1]-[j]之间的最小值。最短是L,所以接下来让j遍历L-n; 3.怎么查找max(sum[i])就是搜索树的了。建立的树序号: 1 2 7 4 5 6 8区间: 0-9 0-4 5-90-2 3-4 5-7 8-9tr[i]... 阅读全文
posted @ 2014-04-10 15:14 y丫t 阅读(201) 评论(0) 推荐(0)
摘要:恶龙的m个头,直径不同,骑士的能力不同,付的金币不同,杀完龙最少的金币,不能杀完输出“...”输入:m nm行表示直径n行表示骑士能杀的直径范围,并且应支付这么的金币0 0 为结束行#includeusing namespace std;#include#include#includeint ans,get,drag,peo,a[20010],b[20010];int main(){ while(scanf("%d%d",&drag,&peo)==2 && drag && peo){ for(int i=0;i=a[get]) 阅读全文
posted @ 2014-01-07 21:56 y丫t 阅读(235) 评论(0) 推荐(0)
摘要:Cycling the words:Sample Input Copy sample input to clipboardPlease think about it carefullySample OutputPlease think about it carefullythink about it carefully Pleaseabout it carefully Please thinkit carefully Please think aboutcarefully Please think about it代码:#include#includeusing namespace std;i 阅读全文
posted @ 2013-12-14 09:48 y丫t 阅读(343) 评论(0) 推荐(0)
摘要: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 阅读(580) 评论(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 阅读(373) 评论(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 阅读(303) 评论(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 阅读(217) 评论(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 阅读(940) 评论(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 阅读(205) 评论(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 阅读(206) 评论(0) 推荐(0)
摘要:Sicily1007. To and FroConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionMo and Larry have devised a way of encrypting messages. They first decide secretly on the number of columns and write the message (letters only) down the columns, padding with extra random letters so as to make a rect 阅读全文
posted @ 2013-11-02 16:47 y丫t 阅读(402) 评论(0) 推荐(0)