题解 CF1103E Radix sum】的更多相关文章

题目传送门 题目大意 给出一个\(n\)个数的序列\(a_{1,2,..,n}\),可以选\(n\)次,每次可以选与上次选的相同的数,问对于\(\forall p\in[0,n-1]\)满足选出来的数进行十进制不进位加法结果为\(p\)的方案数.答案对\(2^{58}\)取模. 思路 乍一看,这是一道\(k=10\)的\(k\)进制\(\text {FWT}\)的板题.但是,我们发现这个模数十分的神仙,于是我们就需要解决下面两个问题: 如何求出\(10^5\)的逆元 如何求出模\(2^{58}\…
类似于uoj272,即$B=10$的情况,然后有以下几个细节问题: 1.答案对$2^{58}$取模可以先使用自然溢出模$2^{64}$,最后对$2^{58}$取模即可 2.为了避免实数,令$\omega=\cos\frac{2\pi}{10}+\sin\frac{2\pi}{10}i$,初始每一个数必然是$\omega^{i}$,相乘也就是多项式乘法 根据$\omega^{10}=1$,可以将其幂次对10取模,即是一个9次多项式 又因为$\omega^{5}=-1$,因此$\omega^{i+5…
前言   [LeetCode 题解]系列传送门:  http://www.cnblogs.com/double-win/category/573499.html   1.题目描述 Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example…
39. Combination Sum Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen from C unlimited number of times. N…
题目链接 神题. 题意:给定一个长度为\(10^5\)的幂级数\(a\),将卷积的下标运算定义为十进制下的不进位加法,求\(a^k\)模\(2^{58}\)的结果.\(k\leq 10^9\). 题解: 考虑在复数域下的做法,那么根据卷积的复合只要将\(a\)看作是\(5\)维的.每一维长度为\(10\)的幂级数,对每一维做长度为\(10\)的循环卷积即可.然而现在是取模甚至不是对质数取模.那么我们需要关心两个问题: \(1\).如何解决求逆元的问题. \(2\).如何在模意义下找到\(10\)…
模拟计算一些分数的和,结果以带分数的形式输出注意一些细节即可 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; /* 模拟计算一些分数的和,结果以带分数的形式输出 注意一些细节即可 */ ; ; //long int范围实际上就是int的范围,sqrt(int)不超过…
001.Two Sum[E] Two SumE 题目 思路 1双重循环 2 排序 3 Hashmap 1.题目 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 exactly one solution. Example: Given nums = [2…
CF622F The Sum of the k-th Powers 题意:给\(n\)和\(k\),让你求\(\sum\limits_{i = 1} ^ n i^k \ mod \ 10^9 + 7\).\((1 \le n \le 10^9,0 \le k \le 10^6)\) 好,我们先不看题,来补一些数学. 考虑这样一个序列 \[ h_0,h_1,\dots,h_n,\dots \] 我们定义它的一个差分序列(一阶) \[ \Delta h_0, \Delta h_1, \dots ,…
可以事先打表观察每个数的约数个数,观察到如果进行替换,若干次后这个数便会被替换成1. 所以我们可以直接暴力的进行区间修改,若这个数已经到达1或2,则以后就不再修改,用并查集和树状数组进行维护. 这个方法用了P2391 白雪皑皑的思想处理,用并查集标记该点已经不再用替换. code: #include<bits/stdc++.h> #include<cctype> #define maxn 300010 #define lowbit(x) (x&(-x)) typedef l…
1.题目描述 2.问题分析 使用hashTable 寻找,target  -  num[i] ,将时间复杂度降低到 O(n): 3.代码 vector<int> twoSum(vector<int>& nums, int target) { map<int ,int> m; ; i < nums.size() ; ++i ){ m[nums[i]] = i; } vector<int> result; ; i < nums.size()…