CodeForces - 1017C The Phone Number】的更多相关文章

题面在这里! 一开始有一种构造猜想,可以把答案降到 sqrt(N) 级别. 考虑把 {1,2,...,n} 分成 sqrt(N) 段,每一段是连续的sqrt(N)个数.然后我们倒着把每一段数放上. 比如 n=9 的时候就形如 7,8,9  ;  4,5,6  ;  1,2,3. 这样就能保证 LIC和LDC都是 sqrt(N),从而答案就是 2sqrt(N). 当然这里 sqrt(N) 要取整,但注意一定要向上取整,比如63取sqrt()是7点几,但是如果按7一段分的话会分成9段,不如8一段分分…
Queries for Number of Palindromes Problem's Link:   http://codeforces.com/problemset/problem/245/H Mean: 给你一个字符串,然后q个询问:从i到j这段字符串中存在多少个回文串. analyse: dp[i][j]表示i~j这段的回文串数. 首先判断i~j是否为回文,是则dp[i][j]=1,否则dp[i][j]=0; 那么dp[i][j]=dp[i][j]+dp[i][j-1]+dp[i+1[j…
D. Number of Parallelograms 题目连接: http://www.codeforces.com/contest/660/problem/D Description You are given n points on a plane. All the points are distinct and no three of them lie on the same line. Find the number of parallelograms with the vertice…
\(>Codeforces \space 980 E. The Number Games<\) 题目大意 : 有一棵点数为 \(n\) 的数,第 \(i\) 个点的点权是 \(2^i\) 你需要删掉 \(k\) 个点,使得删掉这些点后树依然联通,且剩下的点权之和最大,并输出方案 \(n , k \leq 10^6\) 解题思路 : 问题可以转化为选取 \(n - k\) 个点,使得选取的点联通且权值和最大 根据点权是 \(2^i\) 的性质,显然有选取编号为 \(x\) 的点比选取 \(i =…
G. Xor-matic Number of the Graph http://codeforces.com/problemset/problem/724/G 题意:给你一张无向图.定义一个无序三元组(u,v,s)表示u到v的(不一定为简单路径)路径上xor值为s.求出这张无向图所有不重复三元组的s之和.1≤n≤10^5,1≤m≤2*10^5. 想法: 如果做过[Wc2011 xor]这道题目(题解),那么问题变得简单起来了. ①假设我们钦定一个(u,v),设任意一条u->v的路径xor值为X,…
[题目链接]:http://codeforces.com/contest/805/problem/D [题意] 给你一个字符串; 里面只包括a和b; 让你把里面的"ab"子串全都去掉; 方式是, 每次操作可以把"ab"替换成为"bba"; 直到整个字符串里面没有"ab"子串为止 [题解] 从ab开始 ab->bba 左边再加一个a的话 即aab 就相当于在bba左边加了一个a abba -> bbaba bbbba…
题目描述: time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Dima worked all day and wrote down on a long paper strip his favorite number n consisting of l digits. Unfortunately, the strip turned…
http://codeforces.com/contest/245/problem/H 题意:给定一个字符串,每次给个区间,求区间内有几个回文串(n<=5000) 思路:设定pd[i][j]代表i~j这部分是不是一个回文串,这个可以n^2预处理 然后设定f[i][j]代表i~j区间有多少个回文串,由于满足区间加减,因此有 f[i][j]=f[i+1][j]+f[i][j-1]-f[i+1][j-1]+pd[i][j] #include<cstdio> #include<cmath&…
题目链接 C. Substitutes in Number time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Andrew and Eugene are playing a game. Initially, Andrew has string s, consisting of digits. Eugene sends Andrew…
The Minimum Number of Variables 我们定义dp[ i ][ mask ]表示是否存在 处理完前 i 个a, b中存者 a存在的状态是mask 的情况. 然后用sosdp处理出,状态为state的a, 能组成的数字, 然后转移就好啦. #include<bits/stdc++.h> #define LL long long #define LD long double #define ull unsigned long long #define fi first #…