摘要: http://poj.org/problem?id=2115 只是简单地exgcd求解,要注意的是k位存储系统意思是当 i 大于2^k时从头开始计算 1 #include <iostream> 2 #include<cstdio> 3 using namespace std; 4 long long 阅读全文
posted @ 2016-08-03 11:52 Wally的博客 阅读(194) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3970 题目很水,但是要强调的是:要保证N个数据能够完全输入否则会RE 1 #include <iostream> 2 #include<cstdio> 3 #define ll long long 4 using namespace std; 阅读全文
posted @ 2016-08-03 11:45 Wally的博客 阅读(181) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1061 这题的关键就是找方程: 要想青蛙能碰面,就满足方程: (x+m*t) - (y+n*t) = p*l; t:跳的次数 p:两只青蛙相差的圈数 l:纬度线的长度 将上述方程整理得: (n-m)*t + p*l = x-y; 令a=n-m,b 阅读全文
posted @ 2016-08-03 11:40 Wally的博客 阅读(146) 评论(0) 推荐(0) 编辑
摘要: Problem Description A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1.F(1) = 阅读全文
posted @ 2016-07-30 15:35 Wally的博客 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Description Calculate the number of toys that land in each bin of a partitioned toy box. Mom and dad have a problem - their child John never puts his 阅读全文
posted @ 2016-07-29 17:14 Wally的博客 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 在开始刷题之前先让我介绍一下欧几里得和扩展欧几里得。 先介绍什么叫做欧几里德算法 有两个数 a b,现在,我们要求 a b 的最大公约数,怎么求?枚举他们的因子?不现实,当 a b 很大的时候,枚举显得那么的naïve ,那怎么做? 欧几里德有个十分又用的定理: gcd(a, b) = gcd(b 阅读全文
posted @ 2016-07-28 17:02 Wally的博客 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 1.字符串结题(不会超内存,但是代码较长) http://acm.hdu.edu.cn/showproblem.php?pid=1250 1 #include <iostream> 2 #include <cstdio> 3 #include <vector> 4 #include <algorit 阅读全文
posted @ 2016-07-12 15:58 Wally的博客 阅读(204) 评论(0) 推荐(0) 编辑
摘要: //约瑟夫问题,可以了解到有关环形数组的遍历方法#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>using namespace std;int a[100];int main(){ int n,m,c 阅读全文
posted @ 2016-06-05 18:53 Wally的博客 阅读(111) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1513 1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 #include <algorithm> 5 using namespa 阅读全文
posted @ 2016-05-30 21:02 Wally的博客 阅读(98) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1789 我的思路:先在输入过程中求出总被减分数sum,再对deadline由小到大进行排序,然后找出deadline的最大值--day,从day到1依次找出deadline大于等于当前day的最大被减分数--red 阅读全文
posted @ 2016-05-30 17:27 Wally的博客 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 1. memset是以字节为单位,初始化内存块。 int data[10] 比如memset(data,0,4*10==sizeof(data)); 2.memset对于char类型的数组可以将其初始化为任意一个单字符 char data[10] 比如memset(data,'0' / 'a' / 阅读全文
posted @ 2016-05-26 17:03 Wally的博客 阅读(801) 评论(0) 推荐(0) 编辑
摘要: 一个简单的问题,由于读题时不在意导致我交了那么多次,值得反思。。。。 http://acm.nefu.edu.cn/JudgeOnline/problemShow.php?problem_id=1045 1 #include <iostream> 2 #include <cstdlib> 3 #in 阅读全文
posted @ 2016-05-24 14:25 Wally的博客 阅读(145) 评论(0) 推荐(0) 编辑
摘要: http://blog.chinaunix.net/uid-21411227-id-1826986.html 负数的二进制为该负数取反之后加一,即:-n=(~n+1) 二进制的打印: 1 #include <iostream> 2 #include <stdio.h> 3 #include <cst 阅读全文
posted @ 2016-05-11 18:51 Wally的博客 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 2016-05-9 冲刺赛题目是从70~~80题 http://acm.nefu.edu.cn/JudgeOnline/problemShow.php?problem_id=1170 总结: 题做的并不理想,在五个小时的时间里只做出来四道水题,原因有很多。 其一,英语不好翻译不了作者所要表达的意思。 阅读全文
posted @ 2016-05-10 16:34 Wally的博客 阅读(94) 评论(0) 推荐(0) 编辑
摘要: http://acm.nefu.edu.cn/JudgeOnline/problemShow.php?problem_id=1068 这是一个在链表中删除特定字符的代码,学习链表后第一次编写的一个代码。 1 #include <iostream> 2 #include <stdio.h> 3 #in 阅读全文
posted @ 2016-05-03 18:47 Wally的博客 阅读(424) 评论(0) 推荐(0) 编辑
摘要: 左边: http://acm.hdu.edu.cn/showproblem.php?pid=1060 1 #include <iostream> 2 #include <math.h> 3 using namespace std; 4 5 int main() 6 { 7 int n,m,d,i; 阅读全文
posted @ 2016-04-28 22:59 Wally的博客 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 1.一个简单的dp问题 http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=17083 这个题的代码比较简单,状态转移方程也比较容易。现在对于状态转移方程的理解有了不一样的感受,它就好像高中时写通项公式一样,熟练之后就能很快的写出来 阅读全文
posted @ 2016-04-28 20:58 Wally的博客 阅读(1026) 评论(0) 推荐(0) 编辑
摘要: Description 菲波那契数大家可能都已经很熟悉了: f(1)=0 f(2)=1 f(n)=f(n-1)+f(n-2) n>2 因此,当需要其除以某个数的余数时,不妨加一些处理就可以得到。 Description Description 菲波那契数大家可能都已经很熟悉了: f(1)=0 f(2 阅读全文
posted @ 2016-04-22 23:21 Wally的博客 阅读(371) 评论(0) 推荐(0) 编辑
摘要: 1.http://acm.nefu.edu.cn/JudgeOnline/problemShow.php?problem_id=1142 1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 long long sum 阅读全文
posted @ 2016-04-22 11:39 Wally的博客 阅读(735) 评论(0) 推荐(0) 编辑
摘要: 1.len函数: 取字符串的长度 用法:k=len(string_name) k的值是字符串string的长度 2.split函数: 用单字符对目标字符串进行分割 用法:string_name.split(“ ”) 即用空格对字符串string进行分割 3.replace函数: 将目标字符串中的特定 阅读全文
posted @ 2016-04-16 23:25 Wally的博客 阅读(156) 评论(0) 推荐(0) 编辑
摘要: Problem Description 杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。不吉利的数字为所有含有4或62的号码。例如 阅读全文
posted @ 2016-04-16 16:28 Wally的博客 阅读(196) 评论(0) 推荐(0) 编辑
摘要: Description 每到冬天,信息学院的张健老师总爱到二龙山去滑雪,喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。张老师想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度 阅读全文
posted @ 2016-04-13 20:45 Wally的博客 阅读(223) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <algorithm>#include <cstring>#include <stdio.h>using namespace std;const int N=1001;long long data1[N]={0},num_data1=0;//d 阅读全文
posted @ 2016-04-12 20:07 Wally的博客 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , s 阅读全文
posted @ 2016-04-11 21:18 Wally的博客 阅读(126) 评论(0) 推荐(0) 编辑
摘要: Description 辰辰是个很有潜能、天资聪颖的孩子,他的梦想是称为世界上最伟大的医师。为此,他想拜附近最有威望的医师为师。医师为了判断他的资质,给他出了一个难题。医师把他带到个到处都是草药的山洞里对他说:“孩子,这个山洞里有一些不同的草药,采每一株都需要一些时间,每一株也有它自身的价值。我会给 阅读全文
posted @ 2016-04-10 21:17 Wally的博客 阅读(152) 评论(0) 推荐(0) 编辑
摘要: Description 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 给出了一个数字三角形。从三角形的顶部到底部有很多条不同的路径。对于每条路径,把路径上面的数加起来可以得到一个和,你的任务就是找到最大的和。 注意:路径上的每一步只能从一个数走到下一层上和它最近的左边的那个数或者右边的 阅读全文
posted @ 2016-04-10 19:42 Wally的博客 阅读(171) 评论(0) 推荐(0) 编辑
摘要: Problem Description Here is a famous story in Chinese history."That was about 2300 years ago. General Tian Ji was a high official in the country Qi. H 阅读全文
posted @ 2016-04-07 21:19 Wally的博客 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Problem Description The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure. The floo 阅读全文
posted @ 2016-04-06 21:37 Wally的博客 阅读(144) 评论(0) 推荐(0) 编辑
摘要: Problem Description There is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a 阅读全文
posted @ 2016-04-06 20:55 Wally的博客 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Description 黑龙江的五常大米全国闻名,每年到了秋天,农民们把自己家的大米到集市上去买,但由于五常地区还是一个比较落后的地方,还实行物物交换,即农民用大米换白面,可以用来蒸馒头啊!每个集市上大米换白面的比例并不相等,如何能用最少的大米换到最多的白面呢?(单位是斤) Description 阅读全文
posted @ 2016-04-03 16:18 Wally的博客 阅读(288) 评论(0) 推荐(0) 编辑