• CodeForces


    题面在这里!

        显然一段区间的 mul - sum * k = 0 才合法,然鹅我们发现sum * k 对于本题的数据来说最大才是1e18,也就是说mul必须得<=1e18.

        我们不妨从这里入手,因为mul最多只能乘log个>1的数,所以我们用lef[]记录每个数往左第一个不是1的数在哪,于是前后两个位置中间就是一坨子1,讨论一下就好啦。

    #include<bits/stdc++.h>
    #define ll unsigned long long
    using namespace std;
    const int maxn=200005;
    const ll inf=(ll)1e19;
    
    inline int read(){
    	int x=0; char ch=getchar();
    	for(;!isdigit(ch);ch=getchar());
    	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
    	return x;
    }
    
    int a[maxn],n,k,lef[maxn];
    ll sum,mul,ans,w;
    
    inline void solve(){
    	const int ha=k;
    	
    	for(int i=1;i<=n;i++){
    		sum=mul=a[i],ans+=(k==1);
    		for(int pre=i,now=lef[i];;pre=now,now=lef[now]){
    			w=mul-sum*(ll)k;
    			if(w>0&&w%ha==0&&w/ha<pre-now) ans++;
    			
    			if(!now||inf/a[now]<mul) break;
    			mul*=(ll)a[now],sum+=(ll)a[now]+pre-now-1;
    			ans+=(mul==sum*(ll)k);
    		}
    	}
    }
    
    int main(){
    //	freopen("data.in","r",stdin);
    //	freopen("data.out","w",stdout);
    	
    	n=read(),k=read();
    	for(int i=1;i<=n;i++){
    		a[i]=read();
    		lef[i]=(a[i-1]!=1?i-1:lef[i-1]);
    	}
    	
    	solve();
    	
    	cout<<ans<<endl;
    	return 0;
    }
    

      

  • 相关阅读:
    ssh环境的搭建,基于注解和配置文件使用
    myeclipse db browser 新建数据源
    区别jquery对象和dom对象及转换方法
    C++中map容器的说明和使用技巧
    csh shell 语法 例子
    如何选择显示器
    Vim简明教程【CoolShell】
    perl
    perlretut
    ssh 配置详解
  • 原文地址:https://www.cnblogs.com/JYYHH/p/9232219.html
Copyright © 2020-2023  润新知