"题目" 题意:给出n(2e5)个数,可以修改某个数为$1\:to\:k$(2e5),问最少几次修改使$i\in1\:to\:\frac{n}{2}$,$满足a[i] + a[n i+1] = x$ 解法:差分维护取某个值为定值时所需要的最少操作次数。 对于每一对数令 分四类情况讨论: 一、如果定值 ...
分类:
其他好文 时间:
2020-04-22 20:01:14
阅读次数:
137
题意:给你一个长度为偶数n的数组,每次可以将一个元素修改为不大于k的值,要求每个a[i]+a[n-i+1]都相等,求最少操作多少次 题解:假设每一对的和都为X,小的记为mn,大的记为mx; 我们对每一对相应的数考虑,有三种情况:改一个数,改两个数,不改 1.改一个数:当x∈[mn+1,mx+k]; ...
分类:
其他好文 时间:
2020-04-22 13:29:41
阅读次数:
75
题目链接:https://codeforces.com/contest/1343 A Candies 随便做做。 B Balanced Array 随便做做。 D Constant Palindrome Sum 题意:如题目的名字,给一个 $n$ 个数字的数组,要保持对称位置的和恒为常数,但是每个数 ...
分类:
其他好文 时间:
2020-04-22 09:23:49
阅读次数:
69
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have ex ...
分类:
其他好文 时间:
2020-04-21 18:36:52
阅读次数:
67
D - Sum of Large Numbers 题意:题目的大概意思就是存在N+1个数,分别为10100,10100+1,10100+2,10100+3.........10100+N。从中至少选出K个数,求选出的K个数的和总共有多少种。 题解:这一题是一个很好的思维题,你看,选择K数,和选择K+ ...
分类:
其他好文 时间:
2020-04-21 00:27:19
阅读次数:
134
字符串hash+二分答案 "Palindrome poj 3974" 求一个字符串的最长回文子串。 因为在学字符串hash,所以这里用二分答案和字符串hash来做,复杂度是O(N log N),据说manacher算法可以在O(N)解决这个问题,但是我还没学哈哈哈哈以后补吧 题解:枚举回文子串的中心 ...
分类:
其他好文 时间:
2020-04-20 21:27:55
阅读次数:
60
Problem : Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary repr ...
分类:
其他好文 时间:
2020-04-20 11:50:44
阅读次数:
65
此博客链接: 两数相加() 题目链接:https://leetcode-cn.com/problems/add-two-numbers/comments/ class Solution { public ListNode addTwoNumbers(ListNode l1, ListNode l2) ...
分类:
其他好文 时间:
2020-04-20 10:27:00
阅读次数:
77
给你一个整数数组 nums,请你返回其中位数为 偶数 的数字的个数。 示例 1: 输入:nums = [12,345,2,6,7896]输出:2解释:12 是 2 位数字(位数为偶数) 345 是 3 位数字(位数为奇数) 2 是 1 位数字(位数为奇数) 6 是 1 位数字 位数为奇数) 7896 ...
分类:
其他好文 时间:
2020-04-19 22:36:32
阅读次数:
91
Problem : A self dividing number is a number that is divisible by every digit it contains. For example, 128 is a self dividing number because 128 % 1 ...
分类:
其他好文 时间:
2020-04-19 09:12:52
阅读次数:
59