• 校内日常膜你赛————2019.11.11(光棍节快乐


    题目链接:

    T1:Problem 1 DIY 手工 (diy.cpp)

    T2:Problem 2 魔塔 (tower.cpp)

    T3:Problem 3 趣味运动会 (sport.cpp)

    思路:

    T1:打表找规律

    T2:暴力

    T3:状压dp

    代码:

    T1:

    #include <iostream>
    #include <algorithm>
    #include <queue>
    #include <cstdio>
    #include <cstring>
    using namespace std;
    typedef long long LL;
    LL maxn;
    LL ksm(LL x,LL y) {
        LL z=1;
        while(y) {
            if(y&1)z*=x;
            y>>=1;
            x*=x;
        }
        return z;
    }/*
    template<typename T>inline void read(T &x) {
        x=0;
        char ch=getchar();
        T f=1;
        while(!isdigit(ch)) {
            if(ch=='-')f=-1;
            ch=getchar();
        }
        while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
        x=x*f;
    }*/
    void write(LL x) {
        if(x<0) {
            putchar('-');
            write(-x);
        } else {
            if(x/10) write(x/10);
            putchar(x%10+'0');
        }
    }
    int main() {
        // freopen("diy.in","r",stdin);
        // freopen("diy.out","w",stdout);
        int T;
        scanf("%d",&T);
        while(T--) {
            LL N;
            maxn=0;
            scanf("%lld",&N);
            if(N%3==0) {
                printf("%lld
    ",ksm(N/3,3));
                continue;
            } else {
                for(int i=3; i<=10; i++) {
                    for(int j=3; j<=10; j++) {
                        if(N%i==0 && N%j==0 && N%(N-(N/i+N/j))==0) {
                            maxn=max(maxn,(N/i)*(N/j)*(N-(N/i+N/j)));
                        }
                    }
                }
                if(!maxn) puts("-1");
                else {
                    write(maxn);
                    puts("");
                }
            }
        }
        return 0;
    }
    View Code

    T2:

    #include<cstdio>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    int T,n,k,v[10],sum;
    struct node {
        int a[10],b[10];
        int sum;
    } f[100001];
    bool vis[100001];
    void out(int k) {
        if(k==0) {
            cout<<0<<" ";
            return ;
        }
        int num=0,ch[50];
        while(k>0) ch[++num]=k%10,k/=10;
        while(num) putchar(ch[num--]+48);
        putchar(32);
    }
    inline int read() {
        int x=0;
        char ch=getchar();
        while(ch<'0'||ch>'9')ch=getchar();
        while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
        return x;
    }
    bool check(int now) {
        for(int i=1; i<=k; i++)    if(f[now].a[i]>v[i])return false;
        return true;
    }
    void jia(int now) {
        for(int i=1; i<=k; i++) v[i]+=f[now].b[i];
    }
    int main() {
    //    freopen("tower.in","r",stdin);
    //    freopen("tower.out","w",stdout);
        T=read();
        while(T--) {
            n=read(),k=read();
            sum=0;
            memset(vis,false,sizeof vis);
            for(int ll=1; ll<=k; ll++)v[ll]=read();
            for(int i=1; i<=n; i++) {
                for(int j=1; j<=k; j++) f[i].a[j]=read();
                for(int j=1; j<=k; j++) f[i].b[j]=read();
            }
            bool l;
            while(1) {
                l=false;
                for(int i=1; i<=n; i++) {
                    if(vis[i])continue;
                    if(check(i)) jia(i),l=true,sum++,vis[i]=true;
                }
                if(l==false) break;
            }
            out(sum);
            printf("
    ");
            for(int i=1; i<=k; i++)out(v[i]);
            printf("
    ");
        }
    //    fclose stdin;
    //    fclose stdout;
        return 0;
    }
    View Code

    T3:

    #include<set>
    #include<queue>
    #include<vector>
    #include<cstdio>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    typedef long long ll;
    const int mod=1e9+7;
    inline int read() {
        int x=0;
        char ch=getchar();
        while(ch>'9'||ch<'0')ch=getchar();
        while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
        return x;
    }
    int ans[10],f[1<<11][6];
    int main() {
        int T=read();
        while(T--) {
            int n=read(),m=read();
            memset(ans,0,sizeof ans);
            memset(f,0,sizeof f);
            f[0][0]=1;
            while(m--) {
                char c=getchar();
                while(c!='-'&&c!='+')c=getchar();
                int u=read(),v=read();
                if(c=='+') {
                    int kk=(1<<n)-1;
                    int t=(1<<(u-1))|(1<<(v-1));
                    kk^=t;
                    for(int i=kk;; i=(i-1)&kk) {
                        for(int j=1; j<=n/2; ++j) {
                            f[i | t][j] += f[i][j - 1];
                            f[i | t][j] >= mod ? f[i | t][j] -= mod : 0;
                            ans[j] += f[i][j - 1];
                            ans[j] >= mod ? ans[j] -= mod : 0;
                        }
                        if(!i)break;
                    }
                } else {
                    int kk=(1<<n)-1;
                    int t=(1<<(u-1))|(1<<(v-1));
                    kk ^= t;
                    for(int i = kk;; i = (i - 1) &kk) {
                        for(int j = 1; j <= n / 2; ++j) {
                            f[i | t][j] -= f[i][j - 1];
                            f[i | t][j] < 0 ? f[i | t][j] += mod : 0;
                            ans[j] -= f[i][j - 1];
                            ans[j] < 0 ? ans[j] += mod : 0;
                        }
                        if(!i) break;
                    }
                }
                for(int i = 1; i < n / 2; ++i) printf("%d ",(ans[i] + mod) % mod);
                printf("%d
    ",(ans[n / 2] + mod) % mod);
            }
        }
        return 0;
    }
    View Code
  • 相关阅读:
    重写MembershipProvider实现自己的身份验证
    重写MembershipProvider用于事务处理(一)
    ASP.NET 2.0中GridView无限层复杂表头的实现
    用好VS2005之扩展membership服务
    ASP.NET2.0角色控制和管理
    asp.net2.0自带的Provider源码下载
    ASP.NET2.0上传EXCEL文件到gridview中显示
    一次编辑GridView 的所有行
    重写MembershipProvider用于事务处理(二)
    创建表头固定,表体可滚动的GridView
  • 原文地址:https://www.cnblogs.com/ydclyq/p/11838721.html
Copyright © 2020-2023  润新知