https://codeforc.es/problemset/problem/1195/D2 很明显可以看出,任意一个长度为\(l_1\)的数串\(s_1\)和任意一个长度为\(l_2\)的数串\(s_2\)在\(f(s_1,s_2)\)中每个位的贡献的位数是一样的.稍微推一推可以知道,\(calcx\_ijk\)和\(calcy\_ijk\)的公式.然后暴力统计一波各个长度的数串有几个就可以了.小心溢出. #include<bits/stdc++.h> using namespace std…
https://codeforc.es/contest/1195/problem/D1 给\(n\)个等长的十进制数串,定义操作\(f(x,y)\)的结果是"从\(y\)的末尾开始一个一个交替放得到的数",求\(\sum\limits_{i=1}^{n}\sum\limits_{j=1}^{n}f(a_i,a_j)\) 很明显每个第\(k\)位(从1开始)都会恰好在\(2k\)和\(2k-1\)位各贡献\(n\)次.预处理出\(pow10\)然后暴力就可以了. #include<…
一.题目 D2. Submarine in the Rybinsk Sea (hard edition) 二.分析 相比于简单版本,它的复杂地方在于对于不同长度,可能对每个点的贡献可能是有差异的. 但是,题目已经说明$a_{i}$最大知道10的9次方,那么$a_{i}$的长度最大也只有10,所以,我们可以按长度进行分组讨论. 需要注意的是,$a_{i}$确定了在前和在后并且确定了$f(a_{i},b_{i})$中的$b_{i}$的长度后,$a_{i}$对各个位置的贡献其实就确定了,相当于对于每一…
一.题目 D1. Submarine in the Rybinsk Sea (easy edition) 二.分析 简单版本的话,因为给定的a的长度都是定的,那么我们就无需去考虑其他的,只用计算ai的值在每个位置的贡献即可. 因为长度是定的,如果ai在前,那么对所有的a的贡献就是在偶数位的贡献值然后乘以n即可. 如果ai在后,那么对所有ai的贡献就是在奇数位的贡献值然后乘以n. 将两种情况合并,其实就是求ai在每个位置下的贡献,然后乘以n. 时间复杂度是$O(n)$ 三.AC代码 1 #incl…
题目传送门 /* 题意:在n^n的海洋里是否有k块陆地 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 输出完k个L后,之后全部输出S:) 5 10 的例子可以是这样的: LSLSL SLSLS LSLSL SLSLS SSSSS */ #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <string> usi…
传送门:QAQQAQ 题意:自己看 思路:就是一个类似于数位DP的东西... 统计a[i]数位分解的数在每一位出现的个数,即分两种讨论: 1.位数小于当前j,则j会出现在q+i,而且计算顺序互换会计算两遍 2.位数大于等于当前j,则j会出现在j*2-1或j*2 (比赛时光D1就调老半天,D2又太谨慎,结果E没时间做了) 代码: #include<bits/stdc++.h> using namespace std; typedef long long ll; #define m_k make_…
B. Sea and Islands Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/544/problem/B Description A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but yo…
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other. Galya doesn't know…
链接:https://codeforces.com/contest/1131/problem/A 题意: 给两个矩形,一个再上一个在下,求两个矩形合并的周围一圈的面积. 思路: 因为存在下面矩形宽度大于上面,所以先求下面矩形周围面积,再求上方矩形最下一行除外的面积. 代码: #include <bits/stdc++.h> using namespace std; typedef long long LL; int main() { int w1, h1, w2, h2; cin >&g…
题目链接:http://codeforces.com/problemset/problem/451/D D. Count Good Substrings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output We call a string good, if after merging all the consecutive equ…