Raphael_W

2013年5月1日 #

UVa 10071 Back to High School Physics

摘要: Problem BBack to High School PhysicsInput: standard inputOutput: standard outputA particle has initial velocity and constant acceleration. If its velocity after certain time is v then what will its displacement be in twice of that time?InputThe input will contain two integers in each line. Each line 阅读全文

posted @ 2013-05-01 00:55 Raphael_W 阅读(533) 评论(0) 推荐(0) 编辑

UVa 10055 Hashmat the Brave Warrior

摘要: Problem AHashmat the brave warrior Input: standard inputOutput: standard outputHashmat is a brave warrior who with his group of young soldiers moves from one place to another to fight against his opponents. Before fighting he just calculates one thing, the difference between his soldier number and t 阅读全文

posted @ 2013-05-01 00:26 Raphael_W 阅读(114) 评论(0) 推荐(0) 编辑

2013年4月30日 #

[算法竞赛入门经典]5.4.4多少块土地——欧拉定理

摘要: 原题:有一块椭圆的地,你可以在边界上选n个点,并两两连接得到n(n-1)/2条线段。它们最多能把土地分成多少个部分?解:最优方案是不让三条线段交与1点。欧拉公式:V-E+F=2.其中V是顶点(即所有线段的断点数加上交点数),E是边数(即n段椭圆弧加上这些线段被切成的段数),F是面数(即土地块数加上椭圆外那个无穷大的面)。换句话说,只需求出V和E,答案就是E-V+1;不管是定点还是边,计算时都要枚举一条从固定点出发(所以最后要乘以n)的所有对角线。假设该对角线左边有i个点,右边有n-2-i个点,则左右两 边的点两两搭配后在这条对角线上形成了i*(n-2-i)个焦点,得到了i*(n-2-i)+1条 阅读全文

posted @ 2013-04-30 23:59 Raphael_W 阅读(563) 评论(0) 推荐(0) 编辑

2013年4月26日 #

UVa 100 3n+1 Problem

摘要: 1 #include <stdio.h> 2 #define MAXN 1000000 3 int a[MAXN] = { 0, 1, 2 }; 4 int getCycleLength(long long n) 5 { 6 if (n < MAXN && !a[n]) 7 return a[n] = getCycleLength(((n & 1) == 0) ? (n >> 1) : (3 * n + 1)) + 1; 8 else 9 if(n >= MAXN)10 return overBoundry(n);11 ... 阅读全文

posted @ 2013-04-26 15:12 Raphael_W 阅读(104) 评论(0) 推荐(0) 编辑

导航