zoukankan      html  css  js  c++  java
  • 守规矩 题解

    上课闲的没事想到的题,挺水的。。。

    只需要计算出每个数被除了多少次,就是优先级的最长下降子序列

    #include<cstdio>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    #include<cmath>
    #define N 5000005
    using namespace std;
    int n,a[N],q[N],top,ans[N],t;
    int read(){
    	int a=0;char ch=getchar();
    	while(ch<'0'||ch>'9')ch=getchar();
    	while(ch>='0'&&ch<='9'){a=a*10+ch-'0';ch=getchar();}
    	return a;
    }
    int main(){
    	freopen("divid.in","r",stdin);
    	freopen("divid.out","w",stdout);
    	n=read();t=read();
    	for(int i=1;i<=n-1;i++)a[i]=read();
    	for(int i=1;i<n;i++){
    		while(top&&a[i]>q[top])top--;
    		q[++top]=a[i];
    		ans[i+1]=top;
    	}
    	for(int i=t;i<=n;i+=t)
    		printf("%d",ans[i]%2);
    	return 0;
    }


  • 相关阅读:
    登录认证
    json
    关于优化
    网站资源
    设计模式
    Python
    查兰IP
    Linux命令
    centos7.0KVM虚拟化
    Shell数组
  • 原文地址:https://www.cnblogs.com/Ren-Ivan/p/7746669.html
Copyright © 2011-2022 走看看