随笔分类 - 技巧
摘要:C. Three Bags You are given three bags. Each bag contains a non-empty multiset of numbers. You can perform a number of operations on these bags. In on
阅读全文
摘要:链接 来源:牛客网 题目描述 Cg特别喜欢翻转序列! 跨年夜也要继续翻转! 现在有一个长度为n的序列s,Cg将其翻转之后变成了t。 路过的oxy发现了这个t序列,但是oxy不可以直接将序列翻转,她只可以执行一种操作: 选择任意的两个数ai和aj(j>i),花费j−i将两数位置交换 问oxy最少花费多
阅读全文
摘要:D. Ceil Divisions You have an array $a_1,a_2,…,a_n$where ai=i. In one step, you can choose two indices x and y (x≠y) and set \(a_x=\lceil{\frac{a_x}{a
阅读全文
摘要:A. Regular Bracket Sequence A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters + a
阅读全文
摘要:链接 来源:牛客网 题目描述 牛妹手里捧着 T 个数,但每个数都超级超级大。 牛牛有强迫症,一看到数就想把它分解质因数,并记录下它的质因子指数的最小值。 形式化地,对于数 \(x=p_1^{a_1}p_2^{a_2}...p_k^{a_k} ,(a_1,a_2,...,a_k) > 0\),牛牛会记
阅读全文
摘要:链接 直线上有n座山峰,第i座的高度为hi。从某座山峰上放飞一架纸飞机,它可以从左往右依次经过一系列高度严格递减的山头。 假设五座山峰的高度依次是3,4,3,2,1。从第一座山峰上放飞的纸飞机可以依次经过第一、四、五座山峰,但不能经过第二、三座山峰。 对于每座山峰,求出要经过除这座山峰外的每座山峰,
阅读全文
摘要:D. Domino for Young You are given a Young diagram. Given diagram is a histogram with n columns of lengths \(a_1,a_2,…,a_n (a_1≥a_2≥…≥a_n≥1).\) Young d
阅读全文
摘要:Team Work You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is
阅读全文
摘要:C. Berry Jam Karlsson has recently discovered a huge stock of berry jam jars in the basement of the house. More specifically, there were 2n jars of st
阅读全文
摘要:首先,如果有某序列$a_i$,则$\sum_^n|a_i-k|$取最小值时,k为$a_i$的中位数。(因为如果是pos,则pos向靠近中位数的位置移动能更小),这个性质也能dp 有n个人站成一排,每个人有$a_i$张纸牌,求最小移动次数使得每个人纸牌数一样,一张纸牌交给旁边的人记为一次移动。 如果t
阅读全文
摘要:Galahad 魔女要测试骑士的能力,要求他维护一个长度为 n的序列,每次要询问一个区间的和。 但是魔女觉得太简单了,骑士能轻松记住 个数作为前缀和。 于是,魔女要求他回答一个区间的和,但如果某一个数在这个区间出现了多次,这个数只能被计算一次。 输入描述: 第一行两个整数 n,m表示数列长度和询问个
阅读全文

浙公网安备 33010602011771号