UESTC 1050 Different game 构造法
Posted ProLightsfxjh
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UESTC 1050 Different game 构造法相关的知识,希望对你有一定的参考价值。
Different game
Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)
Alice is playing a new game recently. In this game, there are
Alice is asked to divide them into
the sequences are labeled
the LCS(longest common subsequence) of
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
The second line contains
It is guaranteed that
Output
Print the answer module 1000000007 in one line.
Sample input and output
Sample Input | Sample Output |
---|---|
2 2 2 3 |
2 |
Source
My Solution
#include <iostream> #include <cstdio> using namespace std; const int HASH = 1000000007; int main() { int m, n, c; long long ans = 0; scanf("%d%d", &m, &n); for(int i = 1; i <= n; i++){ scanf("%d", &c); ans = (ans + (c/m)*(m*(m-1)/2) + (c%m)*(c%m-1)/2) % HASH; } printf("%lld", ans); return 0; }
Thank you!
以上是关于UESTC 1050 Different game 构造法的主要内容,如果未能解决你的问题,请参考以下文章