题意:给你一个字符串,有2种消除方式:1:消除一个单独的字母,代价为a.2:s[j]到s[k]是s[1]到s[j - 1]的子串,那么s[j]到s[k]可以消除,代价为b,问最小的代价. 思路:官方题解说的很明白了. 代码: #include <bits/stdc++.h> #define LL long long #define INF 0x3f3f3f3f using namespace std; const int maxn = 5010; int dp[maxn]; int v[max…
Compress String 时间限制:2000 ms | 内存限制:65535 KB 难度:3 描写叙述 One day,a beautiful girl ask LYH to help her complete a complicated task-using a new compression method similar to Run Length Encoding(RLE) compress a string.Though the task is difficult, LYH i…
1.5 Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2blc5a3. If the "compressed" string would not become smaller than the original string, your met…
Given a string, replace adjacent, repeated characters with the character followed by the number of repeated occurrences. Assumptions The string is not null The characters used in the original string are guaranteed to be ‘a’ - ‘z’ Examples “abbcccdeee…
题目链接: http://codeforces.com/problemset/problem/710/E E. Generate a String time limit per test 2 secondsmemory limit per test 512 megabytes 问题描述 zscoder wants to generate an input file for some programming competition problem. His input is a string co…
题目链接: E. Generate a String time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output zscoder wants to generate an input file for some programming competition problem. His input is a string consistin…
http://www.codeforces.com/gym/100827/attachments Hill Number Time Limits: 5000 MS Memory Limits: 200000 KB 64-bit interger IO format: %lld Java class name: Main Description A Hill Number is a number whose digits possibly rise and then possibl…
题目链接:http://codeforces.com/contest/706/problem/C #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e5+3; const ll INF=1e18; ll dp[N][2]; string a[N],b[N]; int c[N]; int main() { int n; scanf("%d",&n); for(…
Word Cut 题目连接: http://codeforces.com/problemset/problem/176/C Description Let's consider one interesting word game. In this game you should transform one word into another through special operations. Let's say we have word w, let's split this word in…
http://codeforces.com/problemset/problem/148/D D. Bag of mice time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The dragon and the princess are arguing about what to do on the New Year's Eve…
题目来源:http://codeforces.com/problemset/problem/55/D Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue wit…
传送门:CodeForces - 940E - Cashback 题意:在一个长度为n的数组中,可以分出长度为 k 连续的多个数组b(每个数组 b 的 k 可不相同),然后,可以对每个数组 b 进行删去 k / c 个数的操作: 输出最小的全部数组b的和: 思路:首先要贪心的想到,这个 k 要么等于 c ,要么等于 1 ,才能使总和最小: 所以列出递推方程:hh [ i -1 ] = min(hh[i - 1] + a[ i ] , hh[ i - c]+sum[ i ] - sum[ i…