2018青岛现场赛

Posted smallhester

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2018青岛现场赛相关的知识,希望对你有一定的参考价值。

A - Sequence and Sequence

留坑

 

B - Kawa Exam

留坑

 

C - Flippy Sequence

留坑

 

D - Magic Multiplication

技术分享图片
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<queue>
using namespace std;

#define ll long long
#define llu unsigned long long
#define INF 0x3f3f3f3f
#define PI acos(-1.0)

const int maxn=2e5+5;
int N,M,len;
char str[maxn];
int A[maxn];
int B[maxn];
int pos;
bool getB()
{
    for(int i=0;i<M;i++)
    {
        int now=str[pos++]-0;
        if(A[0]>now && now!=0)
            now=now*10+str[pos++]-0;
        if(now%A[0]==0)
        {
            B[i]=now/A[0];
            if(B[i]>=10)
                return false;
        }
        else
            return false;
    }
    return true;
}

bool getA()
{
    for(int i=1;i<N;i++)
    {
        int now=str[pos++]-0;
        if(B[0]>now && now != 0)
            now=now*10+str[pos++]-0;
        if(now%B[0]==0)
        {
            A[i]=now/B[0];
            if(A[i]>=10)
                return false;
        }
        else
            return false;
        for(int j=1;j<M;j++)
        {
            int now=str[pos++]-0;
            if(A[i]>now && now != 0)
                now=now*10+str[pos++]-0;
            if(A[i]*B[j]!=now)
                return false;
        }
    }
    return true;
    
}
bool solve()
{
    int one=str[0]-0;
    int two=one*10+str[1]-0;
    for(int i=1;i<=9;i++)
    {
        pos=0;
        if(one % i == 0)
        {
            A[0]=i;
            if(getB() && getA() && pos == len)
                return true;
        }
    }
    for(int i=1;i<=9;i++)
    {
        pos=0;
        if(two % i == 0 && two / i <10)
        {
            A[0]=i;
            if(getB() && getA() && pos == len)
                return true;
        }
    }
    return false;
}
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d%d",&N,&M);
        scanf("%s",str);
        len=strlen(str);
        if(solve())
        {
            for(int i=0;i<N;i++)
                printf("%d",A[i]);
            printf(" ");
            for(int i=0;i<M;i++)
                printf("%d",B[i]);
            puts("");
        }
        else
            puts("Impossible");
    }
    return 0;
}
View Code

 

 

E - Plants vs. Zombies

留坑

 

F - Tournament

留坑

 

G - Repair the Artwork

留坑

 

H - Mirror

 

I - Soldier Game

 

J - Books

技术分享图片
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<queue>
using namespace std;

#define ll long long
#define llu unsigned long long
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
const int maxn = 1e5 + 5;

int a[maxn];
int b[maxn];
int main()
{
    int t;
    scanf("%d",&t);
    while (t--)
    {
        int n, m;
        scanf("%d%d", &n, &m);
        int minn = INF;
        int num0 = 0;
        int ca = 1;
        for (int i = 1; i <= n; i++)
        {
            scanf("%d", &a[i]);
            if (a[i] != 0)
            {
                minn = min(minn, a[i]);
                b[ca] = a[i];
                ca++;
            }

            if (a[i] == 0)
                num0++;
        }
        if (n == m)
            puts("Richman");
        else if (num0 > m)
            puts("Impossible");
        else if (num0==0 && m == 0)
        {
            printf("%d
", minn - 1);
        }
        else
        {
            ll sum=0;
            int book = m - num0;
            for (int i = 1; i <= book ; i++)
                sum += b[i];
            int num=INF;
            for (int i = book + 1; i < ca; i++)
                num = min(num, b[i]);
            printf("%lld
", sum+num - 1);
        }


    }
    return 0;
}
View Code

 

 

K - Airdrop

 

L - Sub-cycle Graph

 

M - Function and Function

以上是关于2018青岛现场赛的主要内容,如果未能解决你的问题,请参考以下文章

2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)

2018 ACM-ICPC 青岛站现场赛总结

ACM-ICPC 2018 青岛赛区现场赛 K. Airdrop && ZOJ 4068 (暴力)

ACM-ICPC 2018 青岛赛区现场赛 D. Magic Multiplication && ZOJ 4061 (思维+构造)

青岛 2016ICPC 区域现场赛题目

2017 ACM区域赛现场赛 青岛站 E (polya计数)