http://codeforces.com/contest/1004/problem/C 题意: 在一行上有n个数字,现在在最左边和最右边各放置一个机器人,左右机器人各有一个数字p和q.现在这两个机器人从起点开始分别向右和向左移动,当它们移动到和他们自己数字相同的格子时就会停止,否则就会一直移动下去知道出界.现在要计算出有多少组不重复的(p,q)可以使得这两个机器人不相遇. 思路: 只要去考虑每个数第一次出现的位置和最后出现的位置即可.这题我用了前缀和的思想,首先从左到右扫描一遍,算出1~i这个…
http://codeforces.com/contest/1004/problem/D 题意: 在n×m的方格中,选定一个点(x,y)作为中心点,该点的值为0,其余点的值为点到中心点的曼哈顿距离. 现在给出t个点的值,问是否可以确定一个由t个点组成的方格,方格中的值由这t个点组成,如果有,则任一输出一个方格的规模n.m和中心点的坐标x.y. 思路: 参考了https://blog.csdn.net/FSAHFGSADHSAKNDAS/article/details/80951796的题解. #…
正常没有正方形的限制下,值为i的点个数4i 那么从0开始遍历,第一个不为4i的值就是min(x, y) 由于对称性我们姑且令x为这个值 我们先列举n*m=t的各种情况 对于一对n, m.我们已经知道n,m,x 再由于对称性,我们假设距离(x,y)最远的点在(n, m).(当然也可能在(1,m)) 现在知道了(n,m)到(x,y)为max(a[I]) 列方程就能求出y了 然后再暴力验证就好了 #include <iostream> #include <cstdio> #include…
题目链接:http://codeforces.com/contest/1004/problem/B B. Sonya and Exhibition time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Sonya decided to organize an exhibition of flowers. Since the girl…
C. Sonya and Problem Wihtout a Legend 题目连接: http://codeforces.com/contest/713/problem/C Description Sonya was unable to think of a story for this problem, so here comes the formal description. You are given the array containing n positive integers. A…
C. Sonya and Queries 题目连接: http://codeforces.com/contest/714/problem/C Description Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries,…
题目链接:http://codeforces.com/contest/714/problem/C C. Sonya and Queries time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today Sonya learned about long integers and invited all her friends to…
E. Sonya and Problem Wihtout a Legend time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output Sonya was unable to think of a story for this problem, so here comes the formal description. You are g…
C. Sonya and Queries time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multi…
https://codeforces.com/contest/1080/problem/E 题意 有一个n*m(<=250)的字符矩阵,对于每个子矩阵的每一行可以任意交换字符的顺序,使得每一行每一列都是一个回文串,问最多有多少个这样的子矩阵 思路 首先可以思考如何暴力,枚举四个边界(子矩阵),然后判定一下子矩阵的每一行每一列,这样的复杂度是nmnmn*m 很明显需要找一下规律来优化一下复杂度, 对于每一行来说,最多只能存在一种字母的数量是奇数,这样一定可以保证这一行是回文串 对于每一列来说,因为…