随笔分类 - 基础---倍增
摘要:题目:http://codeforces.com/contest/1189/problem/C 题意:给定n个数,每次查询一个区间$[l,r]$。对这个区间内的数,相邻两个数之和超过10,则得到一个candy,然后将他们之和取模10的结果作为新的数。 一共操作$l-r$次,问这个区间得到的candy
阅读全文
摘要:0601 Genius ACM 0x00「基本算法」例题 描述 给定一个整数 M,对于任意一个整数集合 S,定义“校验值”如下: 从集合 S 中取出 M 对数(即 2∗M 个数,不能重复使用集合中的数,如果 S 中的整 数不够 M 对,则取到不能取为止),使得“每对数的差的平方”之和最大,这个最大值
阅读全文
摘要:There are N cities in a country, and there is one and only one simple path between each pair of cities. A merchant has chosen some pat...
阅读全文
摘要:Pog and Szh are playing games. Firstly Pog draw a tree on the paper. Here we define 1 as the root of the tree.Then Szh choose some nod...
阅读全文
摘要:当我们想要知道从最快地从A走到B时,朴素的想法是找出任何一个点走任意步会到达的地方,但是这样太耗内存。但是实际上可以只记录走1,2,4,8,16步能到达的地方从A出发:若跳8个格子(超过B了,放弃) 若跳4个格子(超过B了,放弃) ...
阅读全文