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\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;
}

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

时间: 2024-10-08 11:30:18

2019 icpc 徐州 解题报告的相关文章

2019.10.03解题报告

总体来说能打的暴力都打了 期望\(100 + 40 + 30 = 170\) 实际\(100 + 40 + 10 = 180\) 数据良心(其实是数据太水惹) T1 第一眼觉得就是要找规律,然后直接找找不出来,所以用暴力搜一下 #include <queue> #include <cstdio> #include <cstring> #include <iostream> using namespace std; const int N = 2011; in

解题报告 smoj 2019初二创新班(2019.3.17)

目录 解题报告 smoj 2019初二创新班(2019.3.17) T1:找玩具 题目描述 题意转化 分析 代码 优化(代码复杂度) T2:闯关游戏 题目描述 分析 代码 T3:子数组有主元素 题目描述 分析 代码(\(O(nm\log n)\)) 优化 代码(\(O(nm)\)) 解题报告 smoj 2019初二创新班(2019.3.17) 时间:2019.3.21 T1:找玩具 题目描述 在游戏开始之前,游戏大师在房间的某些地方隐藏了N个玩具.玩具编号为1到N.您的任务是尽可能多地找到这些玩

2019模拟赛09场解题报告

目录 2019模拟赛09场解题报告 目录la~~ 题一:瞬间移动 题二:食物订购 题三:马蹄印 题四:景观美化 2019模拟赛09场解题报告 标签(空格分隔): 解题报告 Forever_chen 2019.8.20 目录la~~ 题一:瞬间移动 [题面] 有一天,暮光闪闪突然对如何将一个整数序列a1,a2,...,an排序为一个不下降序列起了兴趣.身为一只年轻独角兽的她,只能进行一种叫做"单元转换"(unit shift)的操作.换句话说,她可以将序列的最后一个元素移动到它的起始位置

解题报告-2019.12.16

解题报告-2019.12 题目:6-3[拓展编程题_课后练习3][P215 习题8-三-4] 报数 (20分) 题目详情: 报数游戏是这样的:有n个人围成一圈,按顺序从1到n编好号.从第一个人开始报数,报到m(<n)的人退出圈子:下一个人从1开始报数,报到m的人退出圈子.如此下去,直到留下最后一个人. 本题要求编写函数,给出每个人的退出顺序编号. 函数接口定义:void CountOff( int n, int m, int out[] ); 其中n是初始人数:m是游戏规定的退出位次(保证为小于

2020-3-14 acm训练联盟周赛Preliminaries for Benelux Algorithm Programming Contest 2019 解题报告+补题报告

2020-3-15比赛解题报告+2020-3-8—2020-3-15的补题报告 2020-3-15比赛题解 训练联盟周赛Preliminaries for Benelux Algorithm Programming Contest 2019  A建筑(模拟) 耗时:3ms 244KB 建筑 你哥哥在最近的建筑问题突破大会上获得了一个奖项 并获得了千载难逢的重新设计城市中心的机会 他最喜欢的城市奈梅根.由于城市布局中最引人注目的部分是天际线, 你的兄弟已经开始为他想要北方和东方的天际线画一些想法

解题报告 之 POJ2289 Jamie&#39;s Contact Groups

解题报告 之 POJ2289 Jamie's Contact Groups Description Jamie is a very popular girl and has quite a lot of friends, so she always keeps a very long contact list in her cell phone. The contact list has become so long that it often takes a long time for her

解题报告 之 HDU5326 Work

解题报告 之 HDU5326 Work Description It's an interesting experience to move from ICPC to work, end my college life and start a brand new journey in company. As is known to all, every stuff in a company has a title, everyone except the boss has a direct le

圆锥曲线:椭圆小题解题报告

圆锥曲线:椭圆小题解题报告 注意事项: 由于本人水平有限,部分题目解题方法可能非最优解,如有更好方法欢迎在评论区指正. 部分题目讲解可能过于口语化,导致并不符合官方(人教版教材)的要求,请各位在考试中不要学习,使用正确的,符合要求的用语. 本文中可能存在错别字,望发现者在评论区指正. 本篇博客是为记录本人在完成学校作业的过程中遇到的问题,同时给部分同学作为解题参考用. 本篇博客中绘制图像的工具是geogebra. 1~10题: 1 题目: 已知F~1~,F~2~是椭圆\(x^2/4+y^2/3=

解题报告 之 POJ3057 Evacuation

解题报告 之 POJ3057 Evacuation Description Fires can be disastrous, especially when a fire breaks out in a room that is completely filled with people. Rooms usually have a couple of exits and emergency exits, but with everyone rushing out at the same time