题意:对于一个有序数组,输出和为target的两个元素的下标。题目保证仅有唯一解。 分析: 法一:二分。枚举第一个元素,二分找另一个元素,时间复杂度O(nlogn),非最优解。 class Solution { public: vector<int> twoSum(vector<int>& numb ...
分类:
其他好文 时间:
2020-02-09 22:14:01
阅读次数:
73
"题目" 双周赛最后一题 题意:从起始点开始走,每次只能往前走一步,或者往后走一步,或者直接跳到数值一样的格子。求跳到最后一个格子的最小步数 题解: 一开始以为是动态规划,后来发现用BFS更加简单。动态规划也是可以解的。 ...
分类:
其他好文 时间:
2020-02-09 20:11:57
阅读次数:
72
题目一: 给定nn堆石子,两位玩家轮流操作,每次操作可以从任意一堆石子中拿走任意数量的石子(可以拿完,但不能不拿),最后无法进行操作的人视为失败。 问如果两人都采用最优策略,先手是否必胜。 输入格式 第一行包含整数nn。 第二行包含nn个数字,其中第 ii 个数字表示第 ii 堆石子的数量。 输出格 ...
分类:
其他好文 时间:
2020-02-09 18:27:45
阅读次数:
95
Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the other o ...
分类:
其他好文 时间:
2020-02-08 22:02:58
阅读次数:
86
[十二省联考2019]异或粽子(luogu) Description 题目描述 小粽是一个喜欢吃粽子的好孩子。今天她在家里自己做起了粽子。 小粽面前有 nn 种互不相同的粽子馅儿,小粽将它们摆放为了一排,并从左至右编号为 11 到 nn。第 ii 种馅儿具有一个非负整数的属性值 a_iai?。每种馅 ...
分类:
其他好文 时间:
2020-02-08 18:04:02
阅读次数:
121
求$\displaystyle{\sum_{i=1}^n m^ii^m}(x\le 10^5,n\le10^9)$ 首先转为有更一般的形式$\displaystyle{\sum_{i=1}^nm^if(i)}$其中$f(i)$是$x$次多项式 $\displaystyle{\sum m^xf(x)\ ...
分类:
其他好文 时间:
2020-02-08 17:16:42
阅读次数:
66
题目如下: Given an array of integers arr and an integer d. In one step you can jump from index i to index: i + x where: i + x < arr.length and 0 < x <= d. ...
分类:
其他好文 时间:
2020-02-08 16:04:58
阅读次数:
64
Problem "TODO] [Crisp String" "Done] [Lightning Conductor" ...
分类:
其他好文 时间:
2020-02-08 00:20:51
阅读次数:
48
$$The\ 10th\ Shandong\ Provincial\ Collegiate\ Programming\ Contest$$ $A.Calandar$ 签到 $B.Flipping\ Game$ DP $f[i][j]$表示当前第$i$轮按开关,和最终状态相反的有$j$个的方案数 ,初 ...
分类:
其他好文 时间:
2020-02-07 20:33:55
阅读次数:
71
调用多次readN,所以要重复使用internal buffer """ The read4 API is already defined for you. @param buf, a list of characters @return an integer def read4(buf): # B ...
分类:
其他好文 时间:
2020-02-07 18:42:43
阅读次数:
71