19-11-1-N

就剩一个键了……

以后怎么办呢?

也许可以试试字符映射表……(滑稽

ZJ一下:

我还以为我要死了……

40
Miemeng 10
03:21:50
80
03:21:51
10
03:21:51
100
03:21:51

注意T2的文件提交为AC100的,所以应为$120$分。

T1觉得不会,于是先扔了(只看到$10$分)

T2又以为是容斥,事实上发现只是一个$dp$,和内个伊凡挺像的。

T3只会暴力,先不管它。

最后只有一个问题:

T1的规律找到但是打错了,挂了40分

以后不仅要检查暴力,还要查乱搞和思路的一致性!

这是TJ:

T1

窝只会找规律。

#include <iostream>
#include <cstring>
#include <cstdio>
#define LL long long
#define N 111111
using namespace std;

LL pn,arr[N],val[N];
const int Mod=1e9+7;

LL ppow(LL a,LL b){
	LL res=1;
	while(b){
		if(b&1)res=res*a%Mod;
		a=a*a%Mod;
		b>>=1;
	}
	return res;
}
inline LL magic_function(LL v){
	return (ppow(2,v)-1+Mod)%Mod;
}
int main(){
#ifndef LOCAL
	freopen("game.in" ,"r",stdin);
	freopen("game.out","w",stdout);
#endif
	cin.sync_with_stdio(false);
	cin>>pn;
	for(int i=1;i<=pn;i++){
		cin>>arr[i];
		if(arr[i]!=-1)
			val[arr[i]]++;
	}
	LL beg=0;
	for(int i=1;i<=pn;i++){
		beg+=magic_function(val[i]);
		beg%=Mod;
	}
	LL aft=magic_function(pn-1);
	cout<<(aft-beg+Mod)%Mod<<endl;
}

T2

一个sbdp,我一个dpsb和它搏斗了近一个半小时。

先:设$f_{i}$为处理出来前$i$个的方案数。

发现不行,不行就多设一维,

设了以后……

  • $f_{i,0}$为第$i$位和第$i-1$位不同的方案数。
  • $f_{i,1}$为第$i$位和第$i-1$位相同的方案数。
  • $f_{i,2}$为第$i$位和第$i-1,i-2$位都相同的方案数。
  • $f_{i,3}$为第$i$位和第$i-1$位不同,且之前已有一个区间为$3$连的方案数。
  • $f_{i,4}$为第$i$位和第$i-1$位相同,且之前已有一个区间为$3$连的方案数。

于是暴力转移即可:

//flower

#include <iostream>
#include <cstring>
#include <cstdio>
#define LL long long
#define N 111111

using namespace std;

const int Mod=1e9+7;

LL dp[N][5];
LL len,kn;
LL ppow(LL a,LL b){
	LL res=1;
	while(b){
		if(b&1)res=res*a%Mod;
		a=a*a%Mod;
		b>>=1;
	}
	return res;
}
void prerun(){
	dp[1][0]=kn%Mod;
	dp[2][0]=(kn*kn%Mod-kn%Mod+Mod)%Mod;
	dp[2][1]=kn%Mod;
	for(int i=3;i<=len;i++){
		dp[i][0]=(dp[i-1][1]*(kn-1)%Mod
				 +dp[i-1][0]*(kn-1)%Mod)%Mod;
		dp[i][1]=dp[i-1][0];
		dp[i][2]=dp[i-1][1];
		dp[i][3]=((dp[i-1][2]*(kn-1)%Mod
				  +dp[i-1][3]*(kn-1)%Mod)%Mod
				  +dp[i-1][4]*(kn-1)%Mod)%Mod;
		dp[i][4]=dp[i-1][3];
	}
}
int main(){//sbdp vs dpsb
#ifndef LOCAL
	freopen("flower.in" ,"r",stdin);
	freopen("flower.out","w",stdout);
#endif
	cin.sync_with_stdio(false);
	int T;
	cin>>T;
	while(T--){
		LL ans=0;
		cin>>len>>kn;
		if(len==3){
			cout<<kn%Mod<<endl;
			continue;
		}
		prerun();
		ans=((dp[len][2]+dp[len][3])%Mod+dp[len][4])%Mod;
		cout<<ans<<endl;
	}
}

 

posted @ 2019-11-01 19:06  Miemeng_麦蒙  阅读(168)  评论(0编辑  收藏  举报

小麦在雨中,蒙蒙的雾气

麦蒙不想有人骚扰他,如果有必要 联系 QQ:1755601414

如果你嫌广告大,那就喷我吧,不是博客园的锅。