UESTC 1050 Different game【思维】
来源:互联网 发布:淘宝怎么游戏交易 编辑:程序博客网 时间:2024/06/05 06:11
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 intconst 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); }}
- UESTC 1050 Different game【思维】
- UESTC 1050 Different game 构造法
- UESTC 927 Dart game【思维+Dp】
- UESTC 490 Swap Game
- UESTC 1225 Game Rooms
- UESTC 485 Game (BFS)
- Dart game UESTC
- UESTC - 1269:ZhangYu Speech【思维】
- UESTC 1297 Bank 思维题
- UESTC 1215 (思维题 旋转)
- uestc oj 1488 Flip Game
- 【UESTC 1516 Euclid's Game】
- UESTC - 1263:The Desire of Asuna【思维】
- UESTC 1012 (思维)(找规律)
- UESTC 1051 Eggs broken【思维+期望Dp】
- Plate Game codeforces197A 思维
- UESTC 485 Game(康托,BFS)
- UESTC 929 Dart game 完全背包
- TCP的SO_RCVBUF与SO_SNDBUF的作用与意义
- 2017.07.15日C组模拟赛总结
- 微信分享(网站)ASP.NET
- 拖拽改变表格列宽,可兼容任何框架?
- 学习JavaScript的闭包
- UESTC 1050 Different game【思维】
- 关于javascript中DOM的理解和应用01
- AngularJS ng-repeat表格嵌套循环
- 时间在折腾中溜走
- 当月签到连续天数
- ANR论
- 全志R16平台的parrotv1.1系统的编译手册(分色排版)V1.0
- 百练OJ:1028:Web Navigation
- CCF201412-2 就不老老实实做的Z字扫描!