您的位置:首页 > 其它

AtCoder Regular Contest 071

2017-04-10 08:05 549 查看

C - 怪文書 / Dubious Document

题意:定义一种无序的子序列:在原串中随意地取字符并随意打乱顺序。求多个字符串的最长公共无序子序列。

#include<cstdio>
#include<algorithm>
#define MN 1000001
using namespace std;

const int MOD=1e9+7;
int n,f[MN],m;
inline void M(int &x){while(x>=MOD)x-=MOD;}
int main(){
int i,j;
scanf("%d",&n);f
=n;m=n-1;
for (i=n-1;i;i--) f[i]=1LL*(n-1)*(n-1)%MOD,M(f[i]+=f[i+1]),M(f[i]+=m),M(m+=(i+2>n?1:f[i+2])-1);
printf("%d\n",f[1]);
}


View Code

这几乎是我打过码量最少的比赛。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: