随笔分类 -  ACM

摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4717【题意】:给N个点,给出N个点的方向和移动速度,求每个时刻N个点中任意两点的最大值中的最小值,以及取最小值的时刻【题解】:两个点为例,任意两个点,按照自己的方向移动,一般情况下是,先两点慢慢接近,直到最近距离,然后慢慢远离,后面越来越远,图像画出来有点像抛物线,这题就是抛物线求最小值,三分:先二分时间,按照斜率确定移动方向,直到移动到抛物线的最低端注意题目精度,每次最好分1e-5以上,才能保证正确性【code】: 1 #include 2 #include 3 #include 4 #includ... 阅读全文
posted @ 2013-09-11 21:00 crazy_apple 阅读(548) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4722【题意】: 找GoodNumbers一个数N,如果它每一个位数字之和可以整除10,那么它就是GoodNumbers,比如451就是一个4+5+1=10,求[A,B]之间这样的数的个数【题解】: 先写一个暴力代码用来找规律发现: 0-10 1 0-100 10 0-1000 100 0-990 99 0-992 100 0-997 100 基本规律为 n/10 + (1或0) 加1的情况为:n/10*10到 n 有满足条件的 比如:997: 99 + (990到997是否有满足条... 阅读全文
posted @ 2013-09-11 20:08 crazy_apple 阅读(1140) 评论(2) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2566假设一堆由1分、2分、5分组成的n个硬币总面值为m分,求一共有多少种可能的组合方式(某种面值的硬币可以数量可以为0)。输入数据第一行有一个正整数T,表示有T组测试数据;接下来的T行,每行有两个数n,m,n和m的含义同上。对于每组测试数据,请输出可能的组合方式数;每组输出占一行。Sample Input2 3 5 4 8Sample Output1 2【题解】: 这里没有给出n,m的范围,建议使用第三种【code3】方式解【code1】:暴力O(N*N) 1 #include 2 #include 3.. 阅读全文
posted @ 2013-09-10 21:09 crazy_apple 阅读(542) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4715【code】: 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 #define N 1000151 8 9 int prim[N+10];10 int hash[1000000];11 int mark[1000010];12 int cjsb[1000010];13 int hash_cnt=0;14 int lowbit(int i)15 {16 return i&-i;17 }18 v... 阅读全文
posted @ 2013-09-09 22:00 crazy_apple 阅读(239) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4710【code】: 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 #define N 1000151 8 9 int prim[N+10];10 int hash[1000000];11 int mark[1000010];12 int cjsb[1000010];13 int hash_cnt=0;14 int lowbit(int i)15 {16 return i&-i;17 }18 v... 阅读全文
posted @ 2013-09-09 21:57 crazy_apple 阅读(250) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4707【题目大意】:Lin Ji 的宠物鼠丢了,在校园里寻找,已知Lin Ji 在0的位置,输入N D,N表示校园中点的个数,D表示宠物鼠不可能在距离D之内,接下来N-1行,输入x,y,表示x与y相邻,(相邻两点之间的距离为1,不相邻为inf),不存在环结构。【题解】:用邻接表存储树形结构,然后用DFS遍历图【code】: 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 #define NN 100010 ... 阅读全文
posted @ 2013-09-09 21:23 crazy_apple 阅读(542) 评论(1) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4706【题目大意】: 用a-z排出N的形状,输出大小为3-10的N,如果超过z之后,重新从a开始下面是大小为3的N(其实这里的N是反的,呵呵)a ebdfc g大小为4的Nh ni mojl pk q【code】: 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 char str[11][11][11]; 8 int cnt; 9 10 void solve(int id)11 {12 int n=id,i;13 ... 阅读全文
posted @ 2013-09-09 21:17 crazy_apple 阅读(280) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4712Hamming DistanceTime Limit: 6000/3000 MS (Java/Others)Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 797Accepted Submission(s): 284Problem Description(From wikipedia) For binary strings a and b the Hamming distance is equal to the number o 阅读全文
posted @ 2013-09-09 20:54 crazy_apple 阅读(623) 评论(0) 推荐(0)
摘要:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=13051305: SubstringTime Limit: 2 Sec Memory Limit: 10 MB Submit: 12 Solved: 2 [Submit][Status][Web Board]DescriptionGiven a string s. The length of s is smaller than 1000. You are to caculate the number of different substrings of s.InputThere are mult 阅读全文
posted @ 2013-08-31 21:50 crazy_apple 阅读(398) 评论(0) 推荐(1)
摘要:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=13061306: ManorTime Limit: 1 Sec Memory Limit: 128 MB Submit: 125 Solved: 35 [Submit][Status][Web Board]DescriptionBob有n个正整数,他将这n个整数根据大小划分成两部分。对于小于等于k的整数放在集合A中,其余的放在集合B中。每次他从集合B中取出一个最大的值,将其变成0放入A集合中。然后将A集合中所有的元素都增加a,如果此时A中元素大于k,那么要将该元素放入B中,同时将B集合中剩余的元 阅读全文
posted @ 2013-08-31 21:17 crazy_apple 阅读(277) 评论(0) 推荐(0)
摘要:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=13121312: 榜单Time Limit: 1 Sec Memory Limit: 128 MB Submit: 222 Solved: 84 [Submit][Status][Web Board]DescriptionZZY很喜欢流行音乐,每周都要跟踪世界各地各种榜单,例如Oricon和Billboard,现在给出每周各个单曲的销量请给出每周的TOP5以及TOP5中各个单曲的浮动情况。量的排名是按照本周销量排名,而不是总销量。浮动情况则是较上周的排名变动,也就是说即使某单曲本周销量比上周的差 阅读全文
posted @ 2013-08-31 21:13 crazy_apple 阅读(190) 评论(0) 推荐(0)
摘要:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=13031303: DecimalTime Limit: 1 Sec Memory Limit: 128 MB Submit: 589 Solved: 61 [Submit][Status][Web Board]Description任意一个分数都是有理数,对于任意一个有限小数,我们都可以表示成一个无限循环小数的形式(在其末尾添加0),对于任意一个无限循环小数都可以转化成一个分数。现在你的任务就是将任意一个无限循环小数转化成既约分数形式。所谓既约分数表示,分子和分母的最大公约数是1。Input有多 阅读全文
posted @ 2013-08-31 21:09 crazy_apple 阅读(273) 评论(0) 推荐(0)
摘要:http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11353 1 #include 2 #include 3 #include 4 #include 5 #define PI acos(-1) 6 //using namespace std; 7 struct Nod 8 { 9 int dir; 10 int len; 11 }node[200]; 12 struct Point 13 { 14 double x; 15 double y; 16 }; 17 struct segmemt ... 阅读全文
posted @ 2013-08-30 16:50 crazy_apple 阅读(191) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=2262Goldbach's ConjectureTime Limit:1000MSMemory Limit:65536KTotal Submissions:34323Accepted:13169DescriptionIn 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in which he made the following conjecture:Every even number greater 阅读全文
posted @ 2013-08-23 10:46 crazy_apple 阅读(336) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=3207Ikki's Story IV - Panda's TrickTime Limit:1000MSMemory Limit:131072KTotal Submissions:7021Accepted:2604Descriptionliympanda, one of Ikki’s friend, likes playing games with Ikki. Today after minesweeping with Ikki and winning so many times, he is tired of such ea 阅读全文
posted @ 2013-08-21 11:34 crazy_apple 阅读(292) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=1094Sorting It All OutTime Limit:1000MSMemory Limit:10000KTotal Submissions:24505Accepted:8487DescriptionAn ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest. For example, th 阅读全文
posted @ 2013-08-19 20:52 crazy_apple 阅读(238) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=2226Muddy FieldsTime Limit:1000MSMemory Limit:65536KTotal Submissions:7078Accepted:2622DescriptionRain has pummeled the cows' field, a rectangular grid of R rows and C columns (1 8 #include 9 #include 10 #include 11 #include 12 13 #define N 55 14 #define M N*N 15 using 阅读全文
posted @ 2013-08-19 16:27 crazy_apple 阅读(706) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=3041AsteroidsTime Limit:1000MSMemory Limit:65536KTotal Submissions:12601Accepted:6849DescriptionBessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 8 #include 9 #include10 #include11 #include12 13 #define N 55014 using. 阅读全文
posted @ 2013-08-19 15:07 crazy_apple 阅读(253) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=2060Taxi Cab SchemeTime Limit:1000MSMemory Limit:30000KTotal Submissions:5459Accepted:2286DescriptionRunning a taxi station is not all that simple. Apart from the obvious demand for a centralised coordination of the cabs in order to pick up the customers calling to get a ca 阅读全文
posted @ 2013-08-19 10:47 crazy_apple 阅读(429) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=2728Desert KingTime Limit:3000MSMemory Limit:65536KTotal Submissions:18595Accepted:5245DescriptionDavid the Great has just become the king of a desert country. To win the respect of his people, he decided to build channels all over his country to bring water to every villag 阅读全文
posted @ 2013-08-17 13:13 crazy_apple 阅读(367) 评论(0) 推荐(0)