• 清北刷题冲刺 10-31 p.m


    数列

    #include<iostream>
    #include<cstdio>
    using namespace std;
    long long a,b,ans;
    void f(long long x,long long y){
        if(y==0)return;
        ans+=x/y;
        f(y,x%y);
    }
    int main(){
        freopen("seq.in","r",stdin);freopen("seq.out","w",stdout);
        cin>>a>>b;
        ans=1;
        f(a,b);
        cout<<ans;
    }
    100分 gcd

    车辆销售

    #include<iostream>
    #include<cstdio>
    #include<queue>
    #include<cstring>
    #include<ctime>
    #define maxn 100010
    #ifdef WIN32
    #define PLL "%I64d"
    #else
    #define PLL "%lld"
    #endif
    using namespace std;
    int n,m,num,head[maxn],mx,mn=0x7fffffff,cnt;
    bool vis[maxn];
    struct node{
        int to,pre,v;
    }e[200010*2];
    void Insert(int from,int to,int v){
        e[++num].to=to;
        e[num].v=v;
        e[num].pre=head[from];
        head[from]=num;
    }
    int q[maxn],h,t;
    int res;
    bool flag=0,com[maxn];
    int bfs(int limit){
        h=1;
        while(h<=t){
            int now=q[h];h++;
            if(com[now])continue;
            flag=0;
            for(int i=head[now];i;i=e[i].pre){
                if(e[i].v<limit){
                    flag=1;
                    continue;
                }
                int to=e[i].to;
                if(!vis[to]){
                    res++;
                    vis[to]=1;
                    q[t++]=to;
                }
            }
            if(flag==0)com[now]=1;
        }
        return res;
    }
    int qread(){
        int i=0,j=1;
        char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')j=-1;ch=getchar();}
        while(ch<='9'&&ch>='0')i=i*10+ch-'0',ch=getchar();
        return i*j;
    }
    int main(){
    //    freopen("Cola.txt","r",stdin);
        freopen("car.in","r",stdin);freopen("car.out","w",stdout);
        n=qread();m=qread();
        int x,y,z;
        for(int i=1;i<=m;i++){
            x=qread();y=qread();z=qread();
            Insert(x,y,z);Insert(y,x,z);
            mx=max(mx,z);mn=min(mn,z);
        }
        long long ans;
        for(int i=1;i<=n;i++){
            ans=0;
            memset(q,0,sizeof(q));h=t=1;
            memset(vis,0,sizeof(vis));
            memset(com,0,sizeof(com));
            q[t++]=i;vis[i]=1;
            res=0;
            int p,now;
            for(int j=mx+1;j>=mn-1;j--){
                if(j<0)break;
                now=bfs(j);
                if(j==mx+1){p=now;continue;}
                ans+=1LL*(p-now)*(p-now);
                p=now;
            }
            printf(PLL" ",ans);
        }
    //    cout<<endl<<clock();
    }
    30分 bfs暴力

    取数

    #include<iostream>
    #include<cstdio>
    #define maxn 1000010
    using namespace std;
    int n,m,k,a[maxn];
    long long ans=10000000000000;
    int qread(){
        int i=0,j=1;
        char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')j=-1;ch=getchar();}
        while(ch<='9'&&ch>='0')i=i*10+ch-'0',ch=getchar();
        return i*j;
    }
    void dfs(int pos,int cnt,long long sum){
        if(cnt==k){
            ans=min(ans,sum);
            return;
        }
        if(sum>=ans)return;
        if(pos>=n)return;
        int res=0;
        res+=(n-pos)/m;
        if(res*m<n-pos)res++;
        if(res+cnt<k)return;
        if(cnt==0){
            for(int i=pos+1;i<=n;i++)dfs(i,cnt+1,sum+a[i]);
            return;
        }
        for(int i=pos+m;i<=n;i++){
            dfs(i,cnt+1,sum+a[i]);
        }
    }
    int main(){
        freopen("number.in","r",stdin);freopen("number.out","w",stdout);
    //    freopen("Cola.txt","r",stdin);
        n=qread();m=qread();k=qread();
        for(int i=1;i<=n;i++)a[i]=qread();
        dfs(0,0,0);
        cout<<ans;
    }
    20分 暴力
    预计得分100+30+0
    实际得分100+30+20
    T1有一定的思维量,但是代码很好写,也很容易从辗转相减想到辗转相除。T2T3都写的暴力,T3用的dfs,写的剪枝比较多,所以得到了20分。
    感觉这几天以来上午炸的概率比较大,精神状态不好,下午相对还可以。晚上要保证睡眠充足,尽量以较好的精神面貌迎接上午的考试
    小结
  • 相关阅读:
    SSIS: 使用Lookup 和 Cache transformation 进行数据匹配简单介绍
    Linux(Debain)环境安装WordPress
    [转]Ubuntu 软件安装、查找、卸载--apt-get、apt-cache命令安全
    SSIS 实例 从Ftp获取多个文件并对数据库进行增量更新。
    SSIS DB目录设置 (Integration Services Catalogs)
    SSIS:捕获修改了的数据
    MSSQL:修改tempdb设置增加DW性能
    Mac下安装sbt
    [转] linux下 /etc/profile、~/.bash_profile ~/.profile的执行过程
    [转] Spark-Sql On YARN自动调整Executor数配置
  • 原文地址:https://www.cnblogs.com/thmyl/p/7762139.html
Copyright © 2020-2023  润新知