码迷,mamicode.com
首页 > 其他好文 > 详细

2019 icpc 徐州 解题报告

时间:2019-12-08 10:30:22      阅读:332      评论:0      收藏:0      [点我收藏+]

标签:tps   open   turn   freopen   i++   imp   efi   pen   ble   

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\n",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\n");
        }
        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\n");
            else  printf("Yes\n");
        }
    }
    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\n",a[n],b[n],c[n]);
        else puts("impossible");
    }
    return 0;
}

2019 icpc 徐州 解题报告

标签:tps   open   turn   freopen   i++   imp   efi   pen   ble   

原文地址:https://www.cnblogs.com/hezongdnf/p/12004614.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!