zoukankan      html  css  js  c++  java
  • 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;
    	}
    }
    
  • 相关阅读:
    浏览器网络相关概念
    量化投资:以python为工具
    Quantitative Strategies for Achieving Alpha (三)
    Quantitative Startegies for Achieving Alpha(二)
    Quantitative Strategies for Achieving Alpha(一)
    打开量化投资的黑箱(二)
    打开量化投资的黑箱(一)
    量化投资学习(一)
    handy源码阅读(六):tcp类
    handy源码阅读(六):udp类
  • 原文地址:https://www.cnblogs.com/kalginamiemeng/p/Exam20191101.html
Copyright © 2011-2022 走看看