• Wannafly挑战赛3


    A 珂朵莉

    #include <bits/stdc++.h>
    
    using namespace std;
    typedef long long ll;
    const int maxn = 1e5+5;
    double dp[maxn];
    double sd[maxn];
    ll a[maxn],n,m;
    ll s[maxn],x;
    template<typename T> inline void read(T &x){
    x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
    }
    
    template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
    template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
    template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
    int main(){
    	//freopen("in.txt","r",stdin);
    	ll Max=-INT_MAX;
    	read(n,m);
    	for(int i=1;i<=n;i++)
    		read(a[i]),Max=max(Max,a[i]);
    	s[n+1]=0;
    	for(int i=n;i;i--)
    		s[i]=a[i]+s[i+1];
    	for(int _=1;_<=m;_++){
    		read(x);
    		if(x<Max){
    			puts("YNOI is good OI!");
    			continue;
    		}
    		int lst=n+1;
    		dp[n+2]=0;
    		dp[n+1]=0;
    		sd[n+2]=0;
    		sd[n+1]=0;
    		for(int i=n;i>=1;i--){
    			while(s[i]-s[lst]>x)lst--;
    			dp[i]=((sd[i+1]-sd[lst+1])*1.0/(lst-i))+1.0;
    			sd[i]=sd[i+1]+dp[i];
    		}
    		printf("%.2f
    ",dp[1]);
    	}
    	return 0;
    }
    
    

    B 遇见

    #include <bits/stdc++.h>
     
    using namespace std;
    typedef long long ll;
     
    template<typename T> inline void read(T &x){
    x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
    }
     
    template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
    template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
    template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
     
    ll n,m,k;
    ll Mx,Mn,x;
    const double eps = 1e-8;
    int dcmp(double x){
        if(x>eps) return 1;
        if(x<-eps) return -1;
        return 0;
    }
     
    int main(){
        //freopen("in.txt","r",stdin);
        read(n,m,k);
        if(n==0){
            ll res = 18ll*k/(5ll*m);
            if(18ll*k%(5ll*m)) res++;
            printf("%lld %lld
    ",res,res);
        } else {
            read(x);Mx=Mn=x;
            for(int i=1;i<n;i++){
                read(x);
                Mx=max(x,Mx);
                Mn=min(x,Mn);
            }
            ll r1,r2;
            ll v1=Mx;
            ll v2=Mn;
            r1=(k*18)/((v1+m)*5);
            r2=(k*18)/((v2+m)*5);
            if((k*18)%((v1+m)*5)) r1++;
            if((k*18)%((v2+m)*5)) r2++;
            printf("%lld %lld
    ",r1,r2);
        }
        return 0;
    }
    

    C 位数差

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const int N = 1e5 + 5;
    int sum[N], n, a[N], Rank[N], b[N];
    ll BIT[15];
    inline int lowbit(int x) {
    	return x & (-x);
    }
    inline void add(int p) {
    	while (p < N) {
    		++sum[p];
    		p += lowbit(p);
    	}
    }
    inline int query(int p) {
    	int res = 0;
    	while (p) {
    		res += sum[p];
    		p -= lowbit(p);
    	}
    	return res;
    }
    int main() {
    	ll ans = 0;
    	scanf("%d", &n);
    	for (int i = 1; i <= n; ++i) {
            scanf("%d", a + i);
            b[i] = a[i];
        }
    	sort(b + 1, b + n + 1);
    	BIT[1] = 0;
    	BIT[2] = 10;
    	for (int i = 3; i <= 10; ++i) BIT[i] = BIT[i - 1] * 10;
    	for (int i = 1; i <= n; ++i) Rank[i] = lower_bound(b + 1, b + n + 1, a[i]) - b;
    	for (int i = n; i >= 1; --i) {
    		int now = a[i], bit = 0, flg;
    		if (!now) bit = 1;
    		while (now) {
    			now /= 10;
    			++bit;
    		}
    		while (1) {
    			++bit;
    			flg = BIT[bit] - a[i];
    			int DOWN = lower_bound(b + 1, b + n + 1, flg) - b - 1;
    			if (DOWN == n) break;
    			ans += query(n + 1) - query(DOWN);
    		}
    		add(Rank[i]);
    	}
    	cout << ans << endl;
    	return 0;
    }
    

    D Butterfly2

    #include <bits/stdc++.h>
     
    using namespace std;
    typedef long long ll;
     
    const int maxn = 505;
    char mp[maxn][maxn];
    int n,m;
    int dp[6][maxn][maxn];
     
    int main(){
        //freopen("in.txt","r",stdin);
        scanf("%d%d",&n,&m);
        for(int i=1;i<=n;i++)
            scanf("%s",mp[i]+1);
        int ans = 0;
        int tmp;
        //1
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){//left up X
                if(mp[i][j]!='X') continue;
                dp[0][i][j]=1;
                ans=1;
                if(i!=1&&j!=1&&mp[i-1][j-1]=='X') dp[0][i][j]=dp[0][i-1][j-1]+1;
            }
            for(int j=m;j>=1;j--){//right up O
                if(mp[i][j]!='O') continue;
                dp[1][i][j]=1;
                if(i!=1&&j!=m&&mp[i-1][j+1]=='O') dp[1][i][j]=dp[1][i-1][j+1]+1;
            }
        }
        //2
        for(int i=n;i>=1;i--){
            for(int j=1;j<=m;j++){//left down X
                if(mp[i][j]!='X') continue;
                dp[2][i][j]=1;
                ans=1;
                if(i!=n&&j!=1&&mp[i+1][j-1]=='X') dp[2][i][j]=dp[2][i+1][j-1]+1;
            }
            for(int j=m;j>=1;j--){//right down O
                if(mp[i][j]!='O') continue;
                dp[3][i][j]=1;
                if(i!=n&&j!=m&&mp[i+1][j+1]=='O') dp[3][i][j]=dp[3][i+1][j+1]+1;
            }
        }
         
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(mp[i][j]!='X') continue;
                dp[4][i][j]=1;
                if(i!=1&&mp[i-1][j]=='X') dp[4][i][j]=dp[4][i-1][j]+1;
            }
            for(int j=1;j<=m;j++){
                if(mp[i][j]!='O') continue;
                dp[5][i][j]=1;
                if(i!=1&&mp[i-1][j]=='O') dp[5][i][j]=dp[5][i-1][j]+1;
            }
        }
        // for(int i=1;i<=n;i++)
        //  for(int j=1;j<=m;j++)
        //      printf("%d
    ",dp[0][i][j]);
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++){
                if(i!=1&&i!=n&&j!=1&&j!=m&&mp[i][j]=='X'){
                    if(mp[i-1][j+1]!='O') continue;
                    if(mp[i+1][j+1]!='O') continue;
                    tmp=min(dp[0][i][j],dp[2][i][j]);
                    tmp=min(tmp,dp[1][i-1][j+1]+1);
                    tmp=min(tmp,dp[3][i+1][j+1]+1);
                    for(int k=tmp-1;k>=0;k--){
                        if(dp[4][i+k][j-k]>=k+k+1&&dp[5][i+k][j+k]>=k+k+1) ans=max(ans,k+k+1);
                    }
                }
            }
        cout<<ans<<endl;
        return 0;
    }
    
  • 相关阅读:
    鼠标划过出现子菜单
    让dedecms(织梦)的list标签支持weight排序
    win7 64位无法安装网络打印机
    点击外部链接, 让iframe父页面也跟着显示
    C/C++指针(转)
    OO与设计模式的原则、目标 (转)
    页面添加QQ
    Windows Form 中的鼠标事件
    深入浅出C#消息
    初始化列表
  • 原文地址:https://www.cnblogs.com/foreignbill/p/7816792.html
Copyright © 2020-2023  润新知