暑假第十二测(代码片段)

edsheeran edsheeran     2022-12-21     142

关键词:

技术分享图片

技术分享图片

技术分享图片

技术分享图片

 

题解:第一题:

打表找规律,从12以后每次加49,我一直在前十找规律,,找了半天,以后还是多打点,学聪明点

技术分享图片
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int zl[4] = 1,5,10,50;
ll ans[] = 0,4,10,20,35,56,83,116,155,198,244,292,341,390,439,488,537,586,635,684,733,782,831,880,929,978,1027,1076,1125,1174,1223,1272,1321,1370,1419,1468,1517,1566,1615,1664,1713,1762,1811,1860,1909,1958,2007,2056,2105,2154,2203,2252,2301,2350,2399,2448,2497,2546,2595,2644,2693,2742,2791,2840,2889,2938,2987,3036,3085,3134,3183,3232,3281,3330,3379,3428,3477,3526,3575,3624,3673,3722,3771,3820,3869,3918,3967,4016,4065,4114,4163,4212,4261,4310,4359,4408,4457,4506,4555,4604,4653;
int Ans = 0;
int main()
    
    freopen("a.in","r",stdin);
    freopen("a.out","w",stdout);
    ll n;
    scanf("%I64d", &n);
    if(n <= 12)printf("%I64d
", ans[n]);
    else printf("%I64d
", 49* (n - 12) + ans[12]);
View Code

第二题:

这是一道傻逼题,但我就是没想出来,利用log单增函数就好了,比较log2 x^y. log2 y^x ‘即 ylog2x  xlog2y

技术分享图片
#include <bits/stdc++.h>
using namespace std;

int main()

    freopen("b.in","r",stdin);
    freopen("b.out","w",stdout);
    int T;
    scanf("%d", &T);
    while(T--)
        double a, b;
        scanf("%lf%lf", &a, &b);
           if(a == b)puts("=");continue;
           if(a == 1 && b > 1)puts("<");continue;
        if(b == 1 && a > 1)puts(">");continue;
        if(a*log(b) > b*log(a))puts("<");continue;
        if(a*log(b) < b*log(a))puts(">");continue;
        puts("=");
        //printf("%d
", work(a, b, x, y, aa, bb));
   
    return 0;
View Code

 

第三题:

这道题最开始看着像上司的舞会,但简单画画图就知道会成环,然后就二分图匹配,原题是bzoj数字匹配,把数按质因子个数奇偶拆成两组,最大点独立集

技术分享图片
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int M = 500005;
int a[M], tmp[M];
bool check(int a, int b)
    if(a > b)swap(a, b);
    if(b%a)return 0;
    int d = b/a;
    for(int i = 2; i <= d; i++)
        if(d%i == 0 && d != i)return 0;
    
    return 1;    

struct int id, val;odd[M], even[M];
int h[M], match[M], tot, cnt, t2, t1;
bool vis[M];
struct edgeint v,nxt;G[M<<1];
void add(int u, int v)G[++tot].nxt=h[u]; h[u]=tot; G[tot].v=v;
void init()
    memset(h, 0, sizeof(h));
    memset(match, 0, sizeof(match));
    tot = cnt = t1= t2 = 0;
    


bool find(int u)
    for(int i = h[u]; i; i = G[i].nxt)
        int v = G[i].v;
        if(vis[v])continue;
        vis[v] = 1;
        if(!match[v] || find(match[v]))
            match[v] = u;
            return 1;
        
    
    return 0;


int main()

    freopen("c.in","r",stdin);
    freopen("c.out","w",stdout);
    int T;
    scanf("%d", &T);
    while(T--)
        int n, ans = 0, cur = 0;
        scanf("%d", &n);
        init();
        for(int i = 1; i <= n; i++)
            scanf("%d", &a[i]);
            int tt = a[i];
            int cnt = 0;
            for(int j = 2; j <= a[i]; j++)
                if(a[i]%j == 0)
                    while(a[i]%j == 0) a[i] /= j, cnt++;
                
            if(cnt & 1) odd[++t1].val = tt, odd[t1].id = ++cur;
            else even[++t2].val = tt, even[t2].id = ++cur;
        
        for(int i = 1; i <= t1; i++)
            for(int j = 1; j <= t2; j++)
                if(check(odd[i].val, even[j].val))add(odd[i].id, even[j].id);
        for(int i = 1; i <= t1; i++)
            memset(vis, 0, sizeof(vis));
            if(find(odd[i].id)) ans++;
        
            
        printf("%d
", n - ans);
        
   
    return 0;
View Code
早上洛谷说忌模拟赛,结果真的倒数,而且今天题挺水的,自己太菜了

平时二十二测(代码片段)

 第一题水题未放,今天第二题又读入超时2000*2000的读入要快读啊,上次没长教训第二题:图论题.二维前缀和的应用. 最重要的:这就是一棵树啊标算为:对于不包含环的图,连通块数目=点数-边数,所以利用二维前缀和进行... 查看详情

暑假第十四测(代码片段)

题解:第一题:nlognLIS#include<bits/stdc++.h>usingnamespacestd;constintM=100005;inta[M],f[M];intmain()freopen("lis.in","r",stdin);freopen("lis.out","w",stdout);intn,cnt=0;scanf("%d",&n);for(inti=1 查看详情

第十二周测试(代码片段)

第十二周测试MySort注意:研究sort的其他功能,要能改的动代码,需要答辩模拟实现Linux下Sort-t:-k2的功能。要有伪代码,产品代码,测试代码(注意测试用例的设计)参考Sort的实现。提交博客链接。1importjava.util.*;23publicclassMySort14... 查看详情

暑假第十三测(代码片段)

   题解:第一题:规律可由打表知,需要注意一下容斥原理 #include<bits/stdc++.h>usingnamespacestd;constintM=1e4+10;#definelllonglongintn;llm,Ans,num[M],vis[M];lla[M],qs[M];llgcd(lla,llb)if(!b)returna;r 查看详情

暑假第十五天之每天一些题系列(代码片段)

暑假第十五天之每天一些题系列一、选择题以下程序运行结果是intmain()chara[]="123456789",*p=a;inti=0;while(*p)if(i%2==0)*p='!';i++;p++;puts(a);return0;A.1!3!5!7!9B.!1!3!5!7 查看详情

暑假第十七天之每天一些题系列(代码片段)

暑假第十七天之每天一些题系列一、选择题下列程序段的输出结果为unsignedlongpulArray[]=6,7,8,9,10;unsignedlong*pulPtr;pulPtr=pulArray;*(pulPtr+2)+=2;printf("%d,%d\\n",*pulPtr,*(pulPtr+2));A.8,10B.6,8C 查看详情

java第十二次作业(代码片段)

1.packageSchool.Day13;publicclassColaEmployeeStringname;intmonth;doublemoney;publicdoublegetSalary(intmonth)if(month==this.month)returnmoney=money+100;elsereturnmoney;@OverridepublicStringtoStr 查看详情

第十二周(mysort)(代码片段)

注意:研究sort的其他功能,要能改的动代码,需要答辩模拟实现Linux下Sort-t:-k2的功能。要有伪代码,产品代码,测试代码(注意测试用例的设计)参考Sort的实现。提交博客链接。1importjava.util.*;23publicclassMySort14publicstaticvoidmain(Str... 查看详情

第十二节——文件上传(代码片段)

文件上传测试新建一个jsp页面:upload.jsp<formaction="$pageContext.request.contextPath/quick1"method="post"enctype="multipart/form-data">名称<inputtype="te 查看详情

暑假第十九天之每天一些题系列(代码片段)

暑假第十九天之每天一些题系列一、选择题下面哪个选项可以交换指针p和q所指的int型变量的值A.temp=p;p=q;q=temp;B.temp=*p;*p=*q;*q=temp;C.temp=&p;*p=*q;q=*temp;D.temp=p;*p=*q;q=temp;答案解析:t 查看详情

第十二章—武装飞船(代码片段)

12-1蓝色天空:创建一个背景为蓝色的Pygame窗口。1importsys2importpygame3defrun_game():4#初始化游戏并创建一个屏幕对象5pygame.init()6screen=pygame.display.set_mode((1200,800))7pygame.display.set_caption("AlienInvasion")8#设置背景颜色9bg_color 查看详情

第十二篇camunda系列-事件篇-信号事件(代码片段)

信号事件1.开始事件  通过信号来启动流程实例部署流程和发送信号来启动流程/***部署流程*/@TestpublicvoiddeployFlow()Deploymentdeploy=repositoryService.createDeployment(< 查看详情

第十二篇camunda系列-事件篇-信号事件(代码片段)

信号事件1.开始事件  通过信号来启动流程实例部署流程和发送信号来启动流程/***部署流程*/@TestpublicvoiddeployFlow()Deploymentdeploy=repositoryService.createDeployment(< 查看详情

暑假第十二天之每天一些题系列(代码片段)

暑假第十二天之每天一些题系列一、选择题定义了一维int型数组a[10]后,下面错误的引用是A.a[0]=1B.a[0]=5*2C.a[10]=2D.a[1]=a[2]*a[0]答案解析:a[10]越界访问了,10个元素下标是0-9。在C/C++语言中,下面关... 查看详情

暑假第十八天之每天一些题系列(代码片段)

暑假第十八天之每天一些题系列一、选择题设有以下宏定义,则执行语句:z=2*(N+Y(5+1));后z的值为#defineN3#defineY(n)((N+1)*n)/*这种定义在编程规范中是严格禁止的*/A.出错B.42C.48D.54答案解析:#define定义的符号和宏在预处理... 查看详情

浙江省第十二届省赛beautyofarray(代码片段)

DescriptionEdwardhasanarray A with N integers.Hedefinesthebeautyofanarrayasthesummationofalldistinctintegersinthearray.NowEdwardwantstoknowthesummationofthebeautyofallcontiguoussub 查看详情

第十二课连接和高级连接(代码片段)

一、创建联结join:分成innerjoinleftjoinrightjoin 后面跟着on作为联结条件select*fromproducts;select*fromvendors;select*fromproductsinnerjoinvendorsonproducts.vend_id=vendors.vend_id 其中innerjoin是内连接,left左连接,right 查看详情

暑假第十六测(代码片段)

题解:第一题:为了不重复,我们只能算某一个物品被剩下时不能选的方案;我们枚举第几小的物品不能选,则他前面都能选,所以我们需要的体积是sum[[i-1]--sum[i-1]+v[i]-1,达到这个体积的方案数怎么求,我们可以先倒着做一遍dp;... 查看详情