好久好久好久之前的一个题,今天翻cf,发现这个题没过,补一下. 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…
[题目链接]:http://codeforces.com/contest/798/problem/B [题意] 给你n个字符串; 每次操作,你可以把字符串的每个元素整体左移(最左边那个字符跑到最后面去了) 问你最少经过多少次操作可以使得所有字符串都相同; [题解] 枚举最后每个字符串都变成了哪一个字符串; 然后每个字符串都模拟一下左移的过程;直到相等记录总的移动次数; 或者左移超过了长度的次数;输出不可能能和目标串一样; 记录最小的移动次数就好; [Number Of WA] 0 [完整代码]…
题目链接:http://codeforces.com/contest/798/problem/D 题意:给出两串长度为n的数组a,b,然后要求长度小于等于n/2+1的p数组是的以p为下表a1-ap的和乘以2 大于a数组全部数的总和,b也是同理. 题解:一看到这题一般会想到贪心,由于是二维的贪心,所以一定要想让一维有序,所以可以按照a先排一下序. 得到排序后的数组a',先加上a'然后在依次两两选择b大的加上. #include <iostream> #include <cstring>…
题目链接:http://codeforces.com/contest/798/problem/C 题意:给出一串数字,问如果这串数字的gcd大于1,如果不是那么有这样的操作,删除ai, ai + 1 并且把 ai - a(i + 1), ai + a(i + 1) 放入原来的位置.问是否能够在几步操作后使得串的gcd大于1然后要求最小的操作数. 题解:偶数=偶数*偶数 or 奇数*偶数,奇数=奇数*奇数. 如果整个字符串全是偶数的话肯定gcd是大于1的.介于题目要求的操作,奇数-(or)+奇数=…
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…
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,…
/* CF410div2 B. Mike and strings http://codeforces.com/contest/798/problem/B 字符串 暴力 题意:给你n个串,每次操作可以将某个串的第一个字符放到最后去, 问最少的次数,使得所有字符串都相同 思路:先将所有字符串复制成二倍,然后暴力枚举要变成的串 注意数组都要开二倍.. */ #include <cstdio> #include <algorithm> #include <cstring> #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,…
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file for some programming competition problem. His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually ge…
D. The Next Good String time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In problems on strings one often has to find a string with some particular properties. The problem authors were relu…