02 2018 档案
摘要:1堆石子有n个,两人轮流取.先取者第1次可以取任意多个,但不能全部取完.以后每次取的石子数不能超过上次取子数的2倍。取完者胜.先取者负输出"Second win".先取者胜输出"First win". Input输入有多组.每组第1行是2<=n<2^31. n=0退出. Output先取者负输出"S
阅读全文
摘要:Now Fox Ciel becomes a commander of Tree Land. Tree Land, like its name said, has n cities connected by n - 1 undirected roads, and for any two cities
阅读全文
摘要:Give a tree with n vertices,each edge has a length(positive integer less than 1001). Define dist(u,v)=The min distance between node u and v. Give an i
阅读全文
摘要: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 toys away wh
阅读全文
摘要:推荐博客:https://www.cnblogs.com/patrickzhou/p/5867208.html Consider a tree T with N (1 <= N <= 20,000) nodes numbered 1...N. Deleting any node from the t
阅读全文
摘要:推荐博客 : http://blog.csdn.net/ZHangFFYY/article/details/77871897 我们对一个图的存储基本有两种,邻近矩阵和邻接表 ,在补充一个链式前向星 用此方法存图 , 首先先定义一个结构体数组 struct node { int to, w; // t
阅读全文
摘要:关于树上的分治,分为对 树上点的分治 和 边的分治 首先我们先来了解一下树的重心的定义 : 将树的重心删去以后,会被分出很多的子树,结点最多的树的个数最少,这个点称为树的重心 推荐博客 : https://www.cnblogs.com/Paul-Guderian/p/6782671.html 推荐
阅读全文
摘要:Jamie has recently found undirected weighted graphs with the following properties very interesting: The graph is connected and contains exactly n vert
阅读全文
摘要:B. Jamie and Binary Sequence (changed after round) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output stand
阅读全文
摘要:The swimming area of Berhattan's city beach is marked out with n buoys. The buoys form a straight line. When the buoys were being put into the water,
阅读全文
摘要:Define the simple skewness of a collection of numbers to be the collection's mean minus its median. You are given a list of n (not necessarily distinc
阅读全文
摘要:You are given a sequence of n integers a1, a2, ..., an. Determine a real number x such that the weakness of the sequence a1 - x, a2 - x, ..., an - x i
阅读全文
摘要:先想一个简单的问题 让你去求一个任意一个数 x 在 a 进制下的位数, 那么答案就是 log(a)(x) + 1, (以 a 为底 x 的对数 + 1 ) 现在让你去求 n! 在 a 进制下的位数 答案就是 log(a)( n! ) = log(a)(1*2*3*...*n) = log(a)(1)
阅读全文
摘要:推荐博客 : http://blog.csdn.net/zlambert/article/details/65691838 为了避免重复的计算,人们研究出一种新的计数方法,这种方法的基本思想是:先不考虑重叠的情况,把包含于某内容中的所有对象的数目先计算出来,然后再把计数时重复计算的数目排斥出去,使得
阅读全文
摘要:推荐博客 : http://blog.csdn.net/YJX_xx/article/details/38677947 现让你去计算一下图中多边形内部有多少个格点 至于边上的格点的数目,就通过求一次 gcd 就能得到,求两个点横纵坐标长度的最大公约数再减去 1 ,就是这点线段上的格点数且不算左右端点
阅读全文
摘要:最经典的用法是 用来求一个三角形的面积或是判断个方向 去年的省赛有一个题目是求一个多边型的面积,在这里,用叉积就可以轻松解决 现有一个问题,让你去判断一个点是否在三角形的内部,在这里介绍三种方法 (推荐博客 : http://www.cnblogs.com/TenosDoIt/p/4024413.h
阅读全文
摘要:gcd 是表示两个数的最大公约数 在这里 , gcd(a, b) 是等于 gcd(b, a%b) , 证明如下 : 令 a = kb + p , gcd(a, b) = c , 那么就是 a, b 都可以整除 c , 那么 kb 也可以整除 c ,那么 a - kb 也可以整除 c , 所以 b 和
阅读全文
摘要:Jon fought bravely to rescue the wildlings who were attacked by the white-walkers at Hardhome. On his arrival, Sam tells him that he wants to go to Ol
阅读全文
摘要:After successive failures in the battles against the Union, the Empire retreated to its last stronghold. Depending on its powerful defense system, the
阅读全文
摘要:Last year Bob earned by selling memory sticks. During each of n days of his work one of the two following events took place: A customer came to Bob an
阅读全文
摘要:You are given two strings a and b. You have to remove the minimum possible number of consecutive (standing one after another) characters from string b
阅读全文
摘要:You are given a tree (an undirected acyclic connected graph) with N nodes, and edges numbered 1, 2, 3...N-1. Each edge has an integer value assigned t
阅读全文
摘要:There are n houses in the village and some bidirectional roads connecting them. Every day peole always like to ask like this "How far is it if I want
阅读全文
摘要:推荐博客 : http://blog.csdn.net/lw277232240/article/details/72870644 LCA 就是去寻找最近公共祖先 ,如上图中 10 与 11 的LCA是 6 ,7 和 12 的LCA 是 4 。 通过这个我们可以解决的一类问题就是 求任意两点之间的距离
阅读全文
摘要:int a[100000010]; int main() { int i,len,n; while(scanf("%d",&n)!=EOF){ a[1]=1; len=1; for(int k=2;k=10) { a[i+1]+=a[i]/10; a[i]%=10; ...
阅读全文
摘要:Bizon the Champion isn't just attentive, he also is very hardworking. Bizon the Champion decided to paint his old fence his favorite color, orange. Th
阅读全文
摘要:Let D(x) be the number of positive divisors of a positive integer x. For example, D(2) = 2 (2 is divisible by 1 and 2), D(6) = 4 (6 is divisible by 1,
阅读全文
摘要:如何 快速求一个数的因数的个数 问题 2 : 如何求 1 - n 里所有数约数个数的总和 ? 对于一个所要求的数 n ,我们要求的就是遍历 1 - n , 找有几个数是此数的倍数,将结果累加就可以。 问题3 : 如何求 1 - n 里所有数约数个数最多的数是哪个? 约数定理 : 任意一个数都可以写成
阅读全文
摘要:C. Swap Adjacent Elements time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have an arr
阅读全文
摘要:题目描述 小W在计算一个数列{An},其中A1=1,A2=2,An+2=An+1+An。尽管他计算非常精准,但很快他就弄混了自己的草稿纸,他找出了一些他计算的结果,但他忘记了这些都是数列中的第几项。 输入描述: 每行包括数列中的一项Ak(k<=100000)。 总行数T<=30。 输出描述: 对于每
阅读全文
摘要:You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes. Your task is to
阅读全文
摘要:Woken up by the alarm clock Igor the financial analyst hurried up to the work. He ate his breakfast and sat in his car. Sadly, when he opened his GPS
阅读全文