2019 icpc 徐州 解题报告

Posted hezongdnf

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2019 icpc 徐州 解题报告相关的知识,希望对你有一定的参考价值。

A.Cat

题库链接
给定区间[l,r],求一个最长子区间,使得区间异或和小于等于s,(结论)偶数和偶数后三个数的异或和等于0

#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define cin(a) scanf("%d",&a)
#define pii pair<int,int>
#define ll long long
#define lll __int128
#define gcd __gcd

ll a[10];

int main()
{
#ifdef ONLINE_JUDGE
#else
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif
    int t,cnt;
    cin(t);
    ll l,r,s;
    while(t--)
    {   
        cnt = 0;
        scanf("%lld%lld%lld",&l,&r,&s);
        ll ans = 0;
        if(r - l >= 4)
        {
            if(l%2)
            {
                a[cnt] = l;
                cnt++,l++;
            }
            ll len = r-l+1;
            len = len-(len%4);
            ans = len;
            l = l+len;
        }

        for(ll i = l; i <= r; i++) a[cnt++] = i;
        
        ll mx = 0;
        for(int i = 0; i < cnt; i++)
        {   
            ll res = 0,sum = 0;
            for(int j = 0; j <= i; j++)
            {
                res ^= a[j];
                sum++;
            }
            if(res <= s && sum > mx) mx = sum;
        }
        for(int i = 0;i < cnt; i++)
        {   
            ll res = 0,sum = 0;
            for(int j = 1; j <= i; j++)
            {
                res ^= a[j];
                sum++;
            }
            if(res <= s && sum > mx) mx = sum;
        }
        ans += mx;
        if(ans) printf("%lld
",ans);
        else puts("-1");
    }
    return 0;
}

参考博客https://blog.csdn.net/qq_43627087/article/details/103437359

C.<3 numbers

题库链接
给定区间[l,r],问区间素数个数是否大于区间长度的三分之一
暴力,区间大于100没必要去找了

#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define cin(a) scanf("%d",&a)
#define pii pair<int,int>
#define ll long long
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 200100;

int judge(int n)
{   
    for(int i = 2; i <= sqrt(n); i++)
    {
        if(n%i==0) return 0;
    }
    return 1;
}

int main()
{
    int t;
    cin>>t;
    int l,r;
    while(t--)
    {
        cin>>l>>r;
        if(r-l > 100)
        {
             printf("Yes
");
        }
        else
        {
            int res = 0;
            for(int i = l;i <= r; i++)
            {
                if(judge(i)) res++;
            }
            int n = (r-l+1);
            if(3*res >= n)  printf("No
");
            else  printf("Yes
");
        }
    }
    return 0;
}

F.The Answer to the Ultimate Question of Life, The Universe, and Everything.

题库链接
∣a∣,∣b∣,∣c∣≤5000. a^3 + b^3 + c^3 = x.0 ≤ x ≤ 200,才200暴力打表就行了

#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define cin(a) scanf("%d",&a)
#define pii pair<int,int>
#define ll long long
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 20000;
int n,m,k,t;

int ans[maxn] = {0,-5000,0,5000,1,-5000,1,5000,8,-5000,2,5000,27,-5000,3,5000,64,-5000,4,5000,125,-5000,5,5000,183,-4889,976,4876,181,-4874,974,4861,190,-4812,-593,4815,111,-4793,-2312,4966,161,-4767,-2476,4980,2,-4373,-486,4375,118,-4328,383,4327,87,-4126,-1972,4271,162,-4125,-1417,4180,16,-4114,-588,4118,92,-4052,861,4039,127,-4034,-3881,4988,128,-3989,-726,3997,48,-3950,-1247,3991,54,-3885,-648,3891,160,-3874,-1654,3972,170,-3834,-2149,4047,198,-3752,-1347,3809,153,-3736,-695,3744,83,-3707,1315,3651,155,-3693,-1049,3721,119,-3677,-1673,3789,163,-3423,-2943,4033,91,-3389,-2912,3992,17,-3331,2195,2977,55,-3329,1837,3131,36,-3223,2358,2731,97,-3168,-991,3200,134,-3013,-1766,3203,109,-2948,853,2924,197,-2867,-1606,3026,179,-2839,1503,2691,20,-2816,-741,2833,120,-2804,1219,2725,144,-2746,-2552,3342,62,-2744,-1561,2903,106,-2689,-1165,2760,25,-2683,1839,2357,89,-2514,1953,2036,53,-2370,1518,2141,45,-2369,1709,2025,81,-2368,-1719,2638,147,-2366,1528,2131,70,-2359,824,2325,101,-2327,319,2325,200,-2318,-638,2334,28,-2268,-249,2269,126,-2212,-419,2217,199,-2208,508,2199,154,-2135,-516,2145,26,-2107,237,2106,98,-2101,-1638,2391,78,-2080,-829,2123,116,-1906,-757,1945,187,-1885,-1092,2000,90,-1803,365,1798,100,-1797,-903,1870,189,-1702,-1403,1974,188,-1639,318,1635,129,-1580,-1238,1801,34,-1555,-244,1557,159,-1534,383,1526,88,-1390,-1282,1686,18,-1373,-1276,1671,169,-1354,-1012,1521,135,-1351,-629,1395,171,-1328,891,1178,82,-1317,847,1188,107,-1309,947,1117,80,-1300,-706,1366,60,-1201,-163,1202,177,-1168,-160,1169,108,-1165,-948,1345,35,-1120,-509,1154,136,-1116,816,946,196,-1057,-579,1112,57,-998,361,982,61,-966,668,845,65,-929,403,903,117,-896,-555,962,99,-893,-622,984,43,-823,-307,837,152,-805,486,741,168,-802,-574,890,51,-796,602,659,46,-758,-473,815,137,-758,-428,801,79,-706,-196,711,11,-695,-641,843,56,-672,505,559,10,-650,-353,683,6,-637,-205,644,71,-533,401,443,151,-463,215,447,37,-444,-84,445,72,-432,-104,434,69,-403,134,398,21,-401,-287,445,133,-399,167,389,191,-377,-215,399,150,-367,260,317,174,-335,-170,349,73,-335,-146,344,146,-327,-263,376,15,-265,-262,332,93,-248,-98,253,102,-239,118,229,29,-233,-69,235,9,-216,-52,217,7,-169,44,168,63,-161,102,146,47,-141,49,139,141,-139,104,116,19,-95,47,91,182,-90,-29,91,138,-86,-77,103,164,-66,-59,79,123,-37,-16,38,38,-27,16,25,96,-22,14,20,192,-20,16,16,178,-13,-10,15,115,-12,8,11,12,-11,7,10,24,-10,8,8,145,-8,-7,10,44,-7,-5,8,105,-7,-4,8,142,-7,-3,8,3,-5,4,4,186,-4,5,5,124,-1,0,5,132,-1,2,5,66,1,1,4,inf};
int a[maxn],b[maxn],c[maxn];

int main()
{
#ifdef ONLINE_JUDGE
#else
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif
    int i = 0;
    while(ans[i] != inf)
    {
        int temp = ans[i++];
        a[temp] = ans[i++];
        b[temp] = ans[i++];
        c[temp] = ans[i++];
    }
    cin(t);
    while(t--)
    {
        cin(n);
        if(a[n] || b[n] || c[n]) printf("%d %d %d
",a[n],b[n],c[n]);
        else puts("impossible");
    }
    return 0;
}

以上是关于2019 icpc 徐州 解题报告的主要内容,如果未能解决你的问题,请参考以下文章

2019ICPC徐州站题解

2019ICPC徐州站M题

2019ICPC徐州区域赛 Kill the tree

ICPC2019徐州 现场赛M Kill the tree 树的重心

2020年2月2日 ICPC2019徐州 现场赛C <3 numbers 思维题

ACM-ICPC 2017 Asia HongKong 解题报告