Different game
Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)
Submit Status
Alice is playing a new game recently. In this game, there are nn different kinds of cards. We assume that Alice have cici pieces of cards for ithith kind.
Alice is asked to divide them into mm piles and then arrange each pile in one line. After that, Alice will get mm sequences. For convenience, the sequences are labeled S1,S2,⋯,SmS1,S2,⋯,Sm. For each i<ji<j , Alice will get some points, equal to the length of the LCS(longest common subsequence) of SiSi and SjSj. The total points is the sum of points for all i<ji<j.
Now Alice is wondering the maximum points she can get.
As is known to everyone of you, Bob loves Alice very much. Could you tell Bob the answer to help Bob leave a good impression on Alice.
Input
The first line contains 22 integers mm and nn, indicating the number of sequences and the number of different kinds of card.
The second line contains nn integers cici, indicating the number of ithith card.
It is guaranteed that 1≤n,m≤100000,0≤ci≤1000001≤n,m≤100000,0≤ci≤100000.
Output
Print the answer module 1000000007 in one line.
Sample input and output
|
Sample Input |
Sample Output |
|
2 2 2 3 |
2 |
题目大意:
有N个数字,要求你分成m个序列,每个数字的量已知 。
求ΣLCS(i,j);
思路:
我们均分每个数字即可。
Ans=Σci/m*C(m,2)+m-(ci/m)*C(m-(ci/m),2);
Ac代码:
#include<stdio.h>
#include<string.h>
using namespace std;
#define ll long long int
const ll mod=1e9+7;
ll C(ll x){
return x*(x-1)*500000004;
}
int main()
{
ll n,m;
while(~scanf("%lld%lld",&n,&m))
{
ll output=0;ll x;
for(ll i=1;i<=n;i++)
{
scanf("%lld",&x);
output+=x/m*C(m) + C(x-x/m*m);
output%=mod;
}
printf("%lld\n",output);
}
}
游戏卡片分组策略

本文介绍了一种关于游戏卡片分组的问题,目的是通过最优分配不同种类的卡片到多个序列中,来最大化各序列间的最长公共子序列得分总和。文章提供了一个有效的解决方案,并附带AC代码实现。
740

被折叠的 条评论
为什么被折叠?



