zoukankan      html  css  js  c++  java
  • noip模拟赛

    T1 飞行时间

    对于一个可能跨时区的航班,给定来回程的起降时间。假设飞机来回飞行时间相同,求飞机的飞行时间。

    sol:

    很明显答案是(过去落地 - 过去起飞 + 回来落地 - 回来起飞) / 2

    时间转换要仔细算一下不要跟某省队dalao一样写挂就可以了

    T2 二阶和

    区间修改,求区间区间和的和

    sol:

    维护一阶前缀和数列,修改就是区间加一个等差数列

    只要维护每个地方的首项和公差即可

    T3 合人问题

    一个环,每个点有一个权值,合并两个数的代价是他们权值差的绝对值,然后会生成一个新数,权值为原来在右边那个数的权值

    求把所有数合并起来的最小代价

    sol:

    这种傻题直接做吧

    区间dp

    #include<bits/stdc++.h>
    #define LL long long
    using namespace std;
    inline int read()
    {
        int x = 0,f = 1;char ch = getchar();
        for(;!isdigit(ch);ch = getchar())if(ch == '-')f = -f;
        for(;isdigit(ch);ch = getchar())x = 10 * x + ch - '0';
        return x * f;
    }
    int T;
    char ch1[50],ch2[50],ch3[50],ch4[50],tch[50];
    int solve(char ch[])
    {
        int len = strlen(ch + 1);
        int pos1 = -1,pos2 = -1,plu = 0,pp = len;
        for(int i=1;i<=len;i++)
        {
            if(ch[i] == ':' && pos1 == -1)pos1 = i;
            if(ch[i] == ':' && pos1 != -1)pos2 = i;
            if(ch[i] == '(')plu = ch[i + 2] - '0',pp = i - 1;
        }
        int sum = 0,tmp = 0;sum += plu * 24 * 60 * 60;
        //cout<<plu<<endl;
        for(int i=1;i<pos1;i++)tmp = tmp * 10 + ch[i] - '0';
        sum += tmp * 60 * 60;tmp = 0;
        for(int i=pos1+1;i<pos2;i++)tmp = tmp * 10 + ch[i] - '0';
        sum += tmp * 60;tmp = 0;
        for(int i=pos2+1;i<=pp;i++)tmp = tmp * 10 + ch[i] - '0';
        sum += tmp;
        return sum;
    }
    int main()
    {
        freopen("timezone.in","r",stdin);
        freopen("timezone.out","w",stdout);
        T = read();
        int flg = 0;
        while(T--)
        {
            if(flg){int len = strlen(tch + 1);for(int i=1;i<=len;i++)ch1[i] = tch[i];flg = 0;}
            else scanf("%s",ch1 + 1);
            scanf("%s",ch2 + 1);
            scanf("%s",tch + 1);
            if(strlen(tch + 1) == 4)
            {
                int len = strlen(ch2 + 1);
                for(int i=len+1;i<=len+4;i++)ch2[i] = tch[i - len];
                scanf("%s",ch3 + 1);
            }
            else
            {
                int len = strlen(tch + 1);
                for(int i=1;i<=len;i++)ch3[i] = tch[i];
            }
            scanf("%s",ch4 + 1);
            scanf("%s",tch + 1);
            if(strlen(tch + 1) == 4)
            {
                int len = strlen(ch4 + 1);
                for(int i=len+1;i<=len+4;i++)ch4[i] = tch[i - len];
                //scanf("%s",ch3 + 1);
            }
            else flg = 1;
            int val1 = solve(ch1),val2 = solve(ch2),val3 = solve(ch3),val4 = solve(ch4);
            int fval = -(val1 + val3 - val2 - val4) / 2;
            int a1 = fval / 60 / 60,a2 = (fval - 60 * 60 * a1) / 60,a3 = fval - 60 * 60 * a1 - 60 * a2;
            printf("%02d:%02d:%02d
    ",a1,a2,a3);
        }
    }
    T1
    #include<bits/stdc++.h>
    #define inf 2139062143
    #define ll long long
    #define maxn 210
    using namespace std;
    inline int read()
    {
        int x = 0,f = 1;char ch = getchar();
        for(;!isdigit(ch);ch = getchar())if(ch == '-')f = -f;
        for(;isdigit(ch);ch = getchar())x = 10 * x + ch - '0';
        return x * f;
    }
    int n,dp[maxn][maxn],a[maxn],b[maxn],ans=2147483233;
    int main()
    {
        freopen("merge.in","r",stdin);
        freopen("merge.out","w",stdout);
        n=read();memset(dp,63,sizeof(dp));
        for(int i=1;i<=n;i++) read(),b[i]=b[n+i]=read(),dp[i][i]=dp[n+i][n+i]=0;
        for(int j=1;j<=2*n;j++)for(int i=1;i+j<=2*n;i++)for(int k=i;k<i+j;k++) 
                    dp[i][i+j]=min(dp[i][i+j],dp[i][k]+dp[k+1][i+j]+abs(b[i+j]-b[k]));
        for(int i=1;i<=n;i++) ans=min(ans,dp[i][i+n-1]);
        printf("%d",ans);
    }
    T3
  • 相关阅读:
    性能测试总结(三)--工具选型篇
    什么是性能瓶颈
    基于Linux服务器的性能分析与优化
    常见的APP性能测试指标
    性能测试方案设计的方法和思路
    测试渐进式
    Selenium2Library关键字
    互联网运营工作四大内容
    RF学习过程中遇到的问题
    Robot Framework自动化测试环境的搭建
  • 原文地址:https://www.cnblogs.com/Kong-Ruo/p/9822453.html
Copyright © 2011-2022 走看看