Mutiples on a circle Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 171 Accepted Submission(s): 28 Problem Description Tom has a necklace with n jewels. There is a number on each jewel. Now…
参考了官方题解给的方法: 对于处理循环,官方给了一种很巧妙的方法: #include <cstdio> #include <cstring> #include <cstdlib> #define LL long long int ; ; int N, K; int dp[MAXN][MAXMOD]; int val[MAXN]; ]; ]; void init() { ; i < ; ++i ) len[i] = ; ; i < ; ++i ) len[i]…
Balanced Number Problem Description A balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. More specifically, imagine each digit as a box with weight indicated by the digit. When a pivot is placed at some…
题目链接: http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=677&pid=1003 题意: 求长度为n的序列中,每个字符(a~z)连续出现不超过3次的种数. 分析: 数位dp,设dp[i][j]表示进行到第i个字符,其中当前字符出现j次,然后每次状态转移一下就好了~ 代码: #include <cstdio> const int maxm = 2005, mod = 1e9+7; long long d…