A. Mike and palindrome time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the s…
传送门 Description Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike"…
Codeforces Round #410 (Div. 2) A B略..A没判本来就是回文WA了一次gg C.Mike and gcd problem 题意:一个序列每次可以把\(a_i, a_{i+1}\)换成\(a_i-a_{i+1},a_i+a_{i+1}\),最小次数使gcd不为1 题解: 玩一下发现: 奇数 奇数 \(\rightarrow\) 偶数 偶数 奇数 偶数 $ \rightarrow$ 奇数 奇数 \(\rightarrow\) 偶数 偶数 最后都变成偶数好像就是最优啊,…
A. Mike and palindrome time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the s…
题目连接:http://codeforces.com/contest/798/problem/C C. Mike and gcd problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a sequence A = [a1, a2, ..., an] of length n. He considers…
A. Mike and palindrome time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the s…
Description Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome. A palindrome is a string that reads the same backward as forward, for ex…
A. Mike and palindrome time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a string s consisting of only lowercase English letters. He wants to change exactly onecharacter from the st…
D. Mike and distribution time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it…
C. Mike and gcd problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if…
B. Mike and strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si,…
A 题意:问你恰好修改一个字符,能不能使得字符串变成回文串 题解:显然直接for一遍,如果长度为偶数,那么不一样的必须是1个:如果长度为奇数,那么不一样的也可以是0个 #include<bits/stdc++.h> using namespace std; string s; int main(){ cin>>s; int tmp = 0; for(int i=0;i<s.size();i++){ if(s[i]!=s[s.size()-1-i]) tmp++; } if(t…
如果一开始就满足题意,不用变换. 否则,如果对一对ai,ai+1用此变换,设新的gcd为d,则有(ai - ai+1)mod d = 0,(ai + ai+1)mod d = 0 变化一下就是2 ai mod d = 0 2 ai+1 mod d = 0 也就是说,用两次变换之后,gcd至少扩大2倍,于是,最优方案就是我们将所有的奇数都变成偶数. 只需要找出所有奇数段,答案就是sigma([奇数段的长度/2]+(奇数段的长度 mod 2 ==1 ?)). #include<cstdio> #i…
B. Mike and strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si,…
Description Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. . Mike wants to change his sequence in order to make it beautiful. In o…
题目链接:http://codeforces.com/contest/785 A. Anton and Polyhedrons time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Anton's favourite geometric figures are regular polyhedrons. Note that there…
B - Hongcow Solves A Puzzle 题目连接: http://codeforces.com/contest/745/problem/B Description Hongcow likes solving puzzles. One day, Hongcow finds two identical puzzle pieces, with the instructions "make a rectangle" next to them. The pieces can be…
题目链接: http://www.codeforces.com/contest/666/problem/B 题意: 给你n个城市,m条单向边,求通过最短路径访问四个不同的点能获得的最大距离,答案输出一个满足条件的四个点. 题解: 首先预处理出任意两点的最短距离,用队列优化的spfa跑:O(n*n*logn) 现依次访问四个点:v1,v2,v3,v4 我们可以枚举v2,v3,然后求出v2的最远点v1,v3的最远点v4,为了保证这四个点的不同,直接用最远点会错,v1,v4相同时还要考虑次最远点来替换…
C. Beautiful Numbers 题目连接: http://www.codeforces.com/contest/300/problem/C Description Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains…
B. Nanami's Digital Board 题目连接: http://www.codeforces.com/contest/434/problem/B Description Nanami is an expert at playing games. This day, Nanami's good friend Hajime invited her to watch a game of baseball. Unwilling as she was, she followed him to…
D. Vanya and Treasure 题目连接: http://www.codeforces.com/contest/677/problem/D Description Vanya is in the palace that can be represented as a grid n × m. Each room contains a single chest, an the room located in the i-th row and j-th columns contains t…
D. DZY Loves Strings 题目连接: http://codeforces.com/contest/444/problem/D Description DZY loves strings, and he enjoys collecting them. In China, many people like to use strings containing their names' initials, for example: xyz, jcvb, dzy, dyh. Once DZ…
B. Covered Path Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/problem/B Description The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v1 meters per…
http://codeforces.com/contest/761/problem/C 题意:给出n个串,每个串的初始光标都位于0(列)处,怎样移动光标能够在凑出密码(每个串的光标位置表示一个密码的字符,密码至少包含3种字符:数字,小写字母,特殊符号)的情况下使得移动的光标步数最小. 思路: 因为每个串只提供一个密码,所以我们先预处理计算出每个字符串3种字符的最少移动步数. 然后接下三重循环枚举,分别表示数字,小写字母,特殊符号由第i,j,k行提供. #include<iostream> #i…
http://codeforces.com/contest/761/problem/B 题意: 有一个长度为l的环形跑道,跑道上有n个障碍,现在有2个人,给出他们每过多少米碰到障碍,判断他们跑的是不是同一个跑道. 思路: 如果是同一个跑道,那么障碍与障碍之间的距离是相同的. 所以我们可以先计算出两个人的跑道的障碍之间的距离,然后暴力比较,如果全部一样就是同一个跑道(因为是环形跑道,所以在比较的时候每次都需要将第一个加到最后). #include<iostream> #include<st…
B. Far Relative's Problem 题目连接: http://www.codeforces.com/contest/629/problem/B Description Famil Door wants to celebrate his birthday with his friends from Far Far Away. He has n friends and each of them can come to the party in a specific range of…
题目 题意:求任意连续序列的最大值,这个连续序列可以和其他的 值交换k次,求最大值 思路:暴力枚举所有的连续序列.没做对是因为 首先没有认真读题,没看清交换,然后,以为是dp或者贪心 用了一下贪心,各种bug不对. 这次用了一下优先队列,以前用的不多,看这个博客又学了一下 AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <…
称号: 意甲冠军:给定一个矩阵,每格我们有一个数,然后把两个大象,我希望能够吃的对角线上的所有数字.我问两个最大的大象可以吃值. 分析:这种想法是暴力的主题,计算出每一格放象的话能得到多少钱,然后求出两个不冲突的最大值.我比赛的时候写的方法是先求出每个值,编号之后存到数组里面,然后在通过一系列处理得到,总之非常麻烦.写了一个多小时.最后才发现有一点小错误,没时间了.初始例子也没有通过. 然后看了下别人写的,太简洁了.直接用行和列和和差就能够直接求出来.看来代码能力还很有待提高啊. 我的AC代码:…
A. Salem and Sticks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Salem gave you nn sticks with integer positive lengths a1,a2,…,ana1,a2,…,an. For every stick, you can change its length t…
A. Holiday Of Equality time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citi…