HDOJ 4731 Minimum palindrome】的更多相关文章

Minimum palindrome Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 54    Accepted Submission(s): 18 Problem Description Setting password is very important, especially when you have so many "inte…
Minimum palindrome Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 260    Accepted Submission(s): 127 Problem Description Setting password is very important, especially when you have so many "in…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4731 题解:规律题,我们可以发现当m大于等于3时,abcabcabc……这个串的回文为1,并且字典数最小, m等以1时,直接输出n个a, 现在要解决的就是m=2的情况: 通过自己再纸上面写可以得出当n大于等于9时,最大的回文为4,要字典数最小,所以前四个都为a,后面也可以找到一个最小循环结:babbaa 但是还要讨论最后还剩余几个,如果是小于等于两个,那么添加2个a,否则按循环结添加. AC代码: #…
http://acm.hdu.edu.cn/showproblem.php?pid=4731 就做了两道...也就这题还能发博客了...虽然也是水题 先暴力DFS打表找规律...发现4个一组循环节...尾部特殊判断....然后构造一下... #include <cstdio> #include <string> #include <cstdlib> #include <cstring> #include <iostream> #include &…
M=1:aaaaaaaa…… M=2:DFS+manacher, 暴出N=1~25的最优解,找规律.N<=8的时候直接输出,N>8时,头两个字母一定是aa,剩下的以aababb循环,最后剩余<5全部补a,等于5补aabab. M=3:abcabcabcabc…… #include <cstdio> #include <cstring> using namespace std; const char str[] = "aababb"; int m…
Minimum palindrome Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 586    Accepted Submission(s): 110 Problem Description Setting password is very important, especially when you have so many "in…
题目传送门 /* 求逆序数的四种方法 */ /* 1. O(n^2) 暴力+递推 法:如果求出第一种情况的逆序列,其他的可以通过递推来搞出来,一开始是t[1],t[2],t[3]....t[N] 它的逆序列个数是N个,如果把t[1]放到t[N]后面,逆序列个数会减少t[1]个,相应会增加N-(t[1]+1)个 */ #include <cstdio> #include <cstring> #include <algorithm> using namespace std;…
Minimum palindrome Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 309    Accepted Submission(s): 150 Problem Description Setting password is very important, especially when you have so many "i…
划分树,统计每层移到左边的数的和. Minimum Sum Time Limit: 16000/8000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2959    Accepted Submission(s): 684 Problem Description You are given N positive integers, denoted as x0, x1 ... x…
DP,MLE后改为滚动数组AC. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXN 5001 #define INF 0x3f3f3f3f char str[MAXN]; ][MAXN]; int getmin(int x, int y) { return x<y ? x:y; } int main() { int n; int i, j, k; while (scanf(&q…