2018多校联合训练1

http://acm.hdu.edu.cn/contests/contest_show.php?cid=802

三人三台电脑比赛,然而有个队友鸽了,只有两人打,一共过了5题

1001:水题,只需判断3和4的倍数即可,solved by lyy

#include 
using namespace std;
#define ll long long
int t,n;

int main()
{
    scanf("%d",&t);
    while (t--)
    {
        scanf("%d",&n);
        if (n%3==0) printf("%lld\n",(ll)(n/3)*(n/3)*(n/3));
        else if (n%4==0) printf("%lld\n",2LL*(n/4)*(n/4)*(n/4));
        else printf("-1\n");
    }
    return 0;
}

 

1003:水题,排序之后顺序取点即可, solved by lyy

#include 
using namespace std;
#define ll long long
int t,n;
struct point
{
    int id;
    int x,y;
}p[3005];

bool cmp(point a,point b)
{
    return a.x

 

1011:字符串处理,solved by sdn

/*
  ID: oodt
  PROG:
  LANG:C++
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

using namespace std;

const int maxx=10005;
int n,m,k;
int a[maxx];
int ans = 0,cnt = 0,pos = 0;
int l = 0,r = 0;

int main()
{
#ifdef LOCAL
//    freopen("","r",stdin);
#endif
    int T;
    scanf("%d",&T);
    getchar();
    char str[100];
    int h,m,x,y;
    while(T--)
    {
        scanf("%d%d%s",&h,&m,str);
        if(str[3] == '+')
        {
            if(str[5] <= '9' && str[5] >= '0') x = 10*(str[4]-'0') + str[5] - '0';
            else x = str[4] - '0';
            if(str[5] == '.' || str[6] == '.')
            {
                if(str[5] == '.')
                y = str[6]-'0';
                else
                y = str[7]-'0';
                h += x-8;
                m += y * 6;
            }
            else {
                h += x-8;
            }
        }
        else {
            if(str[5] <= '9' && str[5] >= '0') x = 10*(str[4]-'0') + str[5] - '0';
            else x = str[4] - '0';
            if(str[5] == '.' || str[6] == '.')
            {
                if(str[5] == '.')
                y = str[6]-'0';
                else
                y = str[7]-'0';
                h += -x-8;
                m -= y * 6;
            }
            else {
                h += -8-x;
            }
        }
        if(m < 0) {
            m = (m + 60) % 60;
            h--;
        }
        if(m >= 60){
            m = m % 60;
            h++;
        }
        if(h < 0) h = (h + 24)% 24;
        if(h >= 24) h = h % 24;
        printf("%02d:%02d\n",h,m);
    }
    return 0;
}

 

1004:排序之后,直接暴力往数组里填数即可, solved by lyy

#include 
using namespace std;
#define ll long long
int t,n,m;
int a[100005];
int sum[100005];
struct st
{
    int l,r;
}p[100005];

bool cmp(st a,st b)
{
    if (a.l!=b.l) return a.lr)
            {
                for (int j=l;j<=r;j++)
                {
                    sum[a[j]]=0;
                    l++;
                }
                for (int j=l;jr)
                {
                    for (int j=r;j0) mi++;
                    }
                }
            }
        }
        int ma=p[1].r;
        for (int i=1;i<=m;i++)
        {
            ma=max(ma,p[i].r);
        }
        for (int i=ma+1;i<=n;i++)
        {
            a[i]=1;
        }
        for (int i=1;i<=n;i++)
        {
            printf("%d",a[i]);
            if (i!=n) printf(" ");
        }
        printf("\n");
    }
    return 0;
}

 

1007:打表,然后扔到OEIS里,找到一段python代码,研究一下发现可以二分写, solved by lyy

#include 
using namespace std;
#define ll long long
const ll mod=1000000007;
int t;
ll n;

long long inv(long long a,long long m)
{
    if(a == 1)return 1;
    return inv(m%a,m)*(m-m/a)%m;
}

ll inv2=inv(2,mod);

ll f(ll x)
{
    if (x==1) return 1;
    else return x+f(x/2);
}

ll find(ll n)
{
    ll l=1,r=n;
    ll m;
    while (l<=r)
    {
        m=(l+r)/2;
        if (f(m)

 

你可能感兴趣的:(ACM)