2018.9青岛网络预选赛(B)】的更多相关文章

传送门:Problem K https://www.cnblogs.com/violet-acmer/p/9664805.html 题意: 给你n个数,找出满足条件的最多的数的个数. 题解: 满足条件的数的转化为二进制最高位一定相同,否则,肯定不满足条件,此题就转换为最高位相同的二进制数最多有多少个的问题. AC代码: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm&…
传送门:Problem(B) https://www.cnblogs.com/violet-acmer/p/9664805.html 参考资料: https://blog.csdn.net/qq_40993793/article/details/82762766 https://so.csdn.net/so/search/s.do?q=LCA&t=blog 题意: 给出一棵树,根节点为1. 每条边有一个权值,树上有红色结点m个,其花费为 0 ,其余为黑色,每个黑色结点的花费为其到最近红色祖先的经…
传送门:Problem A https://www.cnblogs.com/violet-acmer/p/9664805.html 题意: 求m个PERFECTs中最多有多少个连续的PERFECT和最少有多少个连续的PERFECT. 题解: 最多:m个连续的PERFECT. 最少:(n-m)NON-PERFECT有(n-m+1)个空,求每个空平均有多少个PERFECT,此时是最少连续的PERFECT. AC代码: #include<iostream> #include<cstdio>…
传送门:Problem C https://www.cnblogs.com/violet-acmer/p/9664805.html 题意: 定义五个指令,判断能否从输入的n条指令中成功跳出循环,如果不能,输出"No",反之,输出"Yes". 题解: 判断某个数[0,255]是否重复来到某一指令,如果有,则肯定是个无限循环,输出"No",反之,可以跳出循环,输出"Yes". AC代码: #include<iostream&…
传送门:Problem J https://www.cnblogs.com/violet-acmer/p/9664805.html 题目大意: BaoBao和DreamGrid玩游戏,轮流按灯的按钮,轮到BaoBao时按下b次,轮到DreamGrid时按下d次,初始时灯是灭的,每次按下按钮等都会持续亮v+0.5秒,如果按之前灯时灭的,则按下后灯会打开,如果灯是亮的,则按下后会从之灯的照明时间为v+0.5,且counter增加1,如果在v+0.5秒每没有再一次按下按钮,灯会熄灭. 给出a,b,c,…
传送门:Problem H https://www.cnblogs.com/violet-acmer/p/9664805.html 题意: BaoBao在一条有刻度的路上行走(哈哈,搞笑),范围为 [0,n],且都是整数,在当前刻度i的前0.5米处(i+0.5)有红绿灯s[i+1],s[i+1]='0'代表红灯,s[i+1]='1'代表绿灯,遇到红灯需要等一秒变成绿灯后才可以来到i+1处. 每隔一秒所有的灯都会变色. 且没来到一个新的起点p,所有的灯都会恢复初始状态. 题解: 打表找规律:对于样…
A题 A Live Love 原题链接:https://pintia.cn/problem-sets/1036903825309761536/problems/1041155943483625472 #include<bits/stdc++.h> #include<stdio.h> #include<iostream> #include<cmath> #include<math.h> #include<queue> #include&…
Press the Button Time Limit: 1 Second      Memory Limit: 131072 KB BaoBao and DreamGrid are playing a game using a strange button. This button is attached to an LED light (the light is initially off), a counter and a timer and functions as follows: W…
BaoBao has just found a rooted tree with n vertices and (n-1) weighted edges in his backyard. Among the vertices, of them are red, while the others are black. The root of the tree is vertex 1 and it's a red vertex.Let's define the cost of a red verte…
传送门:Problem J https://www.cnblogs.com/violet-acmer/p/9720603.html 变量解释: need[ i ] : 第 i 个房间含有的旧灯泡个数. remain[ i ] : 第 i 月后,换完满足条件的房间的旧灯泡后剩余节能灯泡的个数. total[ i ] : 前 i 个月换灯泡的房间数. 题意: 有n个房间,每个房间都有need[ i ] 个旧灯泡等着男主角去换,男主角Lpl每个月都会购买m个节能灯泡,按照输入顺序给房间换灯泡,如果当前…