【codeforces 798B】Mike and strings】的更多相关文章

[题目链接]:http://codeforces.com/contest/798/problem/B [题意] 给你n个字符串; 每次操作,你可以把字符串的每个元素整体左移(最左边那个字符跑到最后面去了) 问你最少经过多少次操作可以使得所有字符串都相同; [题解] 枚举最后每个字符串都变成了哪一个字符串; 然后每个字符串都模拟一下左移的过程;直到相等记录总的移动次数; 或者左移超过了长度的次数;输出不可能能和目标串一样; 记录最小的移动次数就好; [Number Of WA] 0 [完整代码]…
[题目链接]:http://codeforces.com/contest/798/problem/A [题意] 让你严格改变一个字符,使得改变后的字符串为一个回文串; 让你输出可不可能; [题解] 直接无脑暴力改就好; 或者按照回文串的规则; 如果a[i]和a[n-i+1]不同则cnt++ 然后看看最后cnt是不是恰好为1,或者为0然后字符串长度为奇数(那样中间那个字符可以任意改) [Number Of WA] 0 [完整代码] #include <bits/stdc++.h> using n…
[题目链接]:http://codeforces.com/contest/798/problem/C [题意] 给你n个数字; 要求你进行若干次操作; 每次操作对第i和第i+1个位置的数字进行; 将 a[i]变为a[i]-a[i+1],a[i+1]变为a[i]+a[i+1]; 然后问你能不能通过以上变换使得最后所有元素的gcd>1 [题解] 答案总是存在的; 因为把这个操作进行两次可以得到-2*a[i+1],2*a[i] 也就是如果对每相邻的元素进行操作,最后都能使得这两个元素都变成偶数; 最后…
[题目链接]:http://codeforces.com/contest/798/problem/D [题意] 让你选一个下标集合 p1,p2,p3..pk 使得2*(a[p1]+a[p2]+..+a[pk])>∑ai 同时2*(b[p1]+b[p2]+..+b[pk])>∑bi [题解] 两个式子都可以转化为 a[p1]+a[p2]+..+a[pk]>剩余的元素 (移项就能得到) 接着用构造的方法搞; 首先把A数组降序排; (排的时候要记录每个元素它原来的下标) 即a[i].val和a…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output After returned from forest, Alyona started reading a book. She noticed strings s and t, lengths of which are n and m respectively. As usual, rea…
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=2000),问满足[数列长度是k && 数列中每一个元素arr[i]在1~n之间 && 数列中元素可以重复]的数列有多少个?结果对10^9+7取余 解题思路:dp[i][j]表示长度是j,最后一位是i的种数 if(kk%i==0) dp[kk][j+1]+=dp[i][j] #inc…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalen…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones. Once he thought ab…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Professor GukiZ doesn't accept string as they are. He likes to swap some letters in string to obtain a new one. GukiZ has strings a, b, and c. H…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output PolandBall is playing a game with EnemyBall. The rules are simple. Players have to say words in turns. You cannot say a word which was already sa…