摘要:G - Apple TreeCrawling in process... Crawling failed Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Practice POJ 3321DescriptionThere is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much,
阅读全文
摘要:F - MooFestTime Limit:1000MS Memory Limit:30000KB 64bit IO Format:%I64d & %I64u Submit StatusAppoint description:DescriptionEvery year, Farmer John's N (1 <= N <= 20,000) cows attend "MooFest",a social gathering of cows from around the world. MooFest involves a variety of eve
阅读全文
摘要:E - Mobile phonesTime Limit:5000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit StatusAppoint description:DescriptionSuppose that the fourth generation mobile phone base stations in the Tampere area operate as follows. The area is divided into squares. The squares form an S * S matr
阅读全文
摘要:D - Balanced LineupCrawling in process... Crawling failed Time Limit:5000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit StatusDescriptionFor the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game
阅读全文
摘要:B - Ping pongCrawling in process... Crawling failed Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit StatusDescriptionN(3<=N<=20000) ping pong players live along a west-east street(consider the street as a line segment). Each player has a unique skill rank. To im
阅读全文
摘要:C - Color the ball(卡java)Time Limit:3000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit StatusAppoint description:DescriptionN 个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗?Input每个测试
阅读全文
摘要:JapanTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 14431Accepted: 3868DescriptionJapan plans to welcome the ACM ICPC World Finals and a lot of roads must be built for the venue. Japan is tall island with N cities on the East coast and M cities on the West coast (M <= 1000, N <= 1000
阅读全文
摘要:树状数组:它能够高效地获取数组中连续n个数的和.数组{a}中的元素可能不断地被修改,怎样才能快速地获取连续几个数的和?2、树状数组基本操作传统数组(共n个元素)的元素修改和连续元素求和的复杂度分别为O(1)和O(n)。树状数组通过将线性结构转换成伪树状结构(线性结构只能逐个扫描元素,而树状结构可以实现跳跃式扫描),使得修改和求和复杂度均为O(lgn),大大提高了整体效率。给定序列(数列)A,我们设一个数组C满足C[i]=A[i–2^k+1]+…+A[i]其中,k为i在二进制下末尾0的个数,i从1开始算!则我们称C为树状数组。下面的问题是,给定i,如何求2^k?答案很简单:2^k=i&(
阅读全文
摘要:树状数组 武钢三中 吴豪 【引言】 在解题过程中,我们有时需要维护一个数组的前缀和 S[i]=A[1]+A[2]+...+A[i]。但是不难发现, 如果我们修改了任意一个A[i],S[i]、S[i+1]...S[n]都会发生变化。可以说,每次修改A[i]后,调 整前缀和 S[]在最坏情况下会需要 O(n)的时间。当n 非常大时,程序会运行得非常缓慢。因此,这里我 们引入“树状数组”,它的修改与求和都是 O(logn)的,效率非常高。 【理论】 为了对树状数组有个形 象的认识,我们先看下面这张图。 如图所示,红色矩形表示的数组 C[]就是树状数组。 这里,C[i]表示A[i-2^k+1...
阅读全文