模拟
文章平均质量分 68
旺 崽
这个作者很懒,什么都没留下…
展开
-
LeetCode 1882 使用服务器处理任务
题目链接给你两个 下标从 0 开始 的整数数组 servers 和 tasks ,长度分别为 n 和 m 。servers[i] 是第 i 台服务器的 权重 ,而 tasks[j] 是处理第 j 项任务 所需要的时间(单位:秒)。你正在运行一个仿真系统,在处理完所有任务后,该系统将会关闭。每台服务器只能同时处理一项任务。第 0 项任务在第 0 秒可以开始处理,相应地,第 j 项任务在第 j 秒可以开始处理。处理第 j 项任务时,你需要为它分配一台原创 2021-05-31 20:32:14 · 2163 阅读 · 0 评论 -
CSP 201703-3 Markdown
题目链接字符串模拟~我觉得这种模拟出得非常好,测试点给得很清楚,你就可以按测试点一个一个来,我们不难发现,区块的三种类型其实一样的,标题和无序列表其实就多了几个前缀,所以我们写一个段落处理的函数即可:题目明确说明超链接和强调会嵌套,所以我们要设两个变量,一个判断超链接里的强调,一个判断超链接外的,因为强调成对出现,只需要判断变量奇偶即可~处理超链接的时候比较麻烦,我们可以观察,超链接一定是以 ‘[’ 开始,以 ‘)’ 结尾,于是我们可以设一个 flag 进行分界,分别提取 [] 和 () 中的内容原创 2021-04-10 10:30:59 · 1915 阅读 · 0 评论 -
CSP 201812-3 CIDR合并
题目链接模拟+位运算~设置IP前缀结构体:ip,地址表示的十进制数a,b,c,d,地址对应的四段十进制数len,地址的前缀长度首先对输入的字符串操作,存入标准型的地址前缀,然后根据题目后面的三种操作写三个函数即可:简单排序函数若 a 包含 b 的匹配集,证明 a.len<b.len,且在 a 的高 a.len 位上和 b 的高 a.len 位一定相等比较复杂的操作,注意题目说两者前缀长度相同,此时我们需要用一个新的 IP 前缀 a’ 来替代现有的,题目讲得很清楚,将 a 的前原创 2021-04-09 21:51:59 · 1862 阅读 · 0 评论 -
CSP 201912-4 区块链
题目链接BFS 模拟~用一个二维数组存每个结点的主链,然后对每个结点建立结构体:currentTime——现在时刻id——邻居结点对应的链编号now——当前结点编号father——邻居结点编号把每个结点放入一个队列中进行 BFS 操作即可,每次操作判断是否更新当前结点的主链并修改邻居结点即可,具体注释见代码,AC代码如下:#include <bits/stdc++.h>using namespace std;typedef long long ll;const in原创 2021-04-07 20:56:41 · 1880 阅读 · 0 评论 -
团体程序设计天梯赛 L2-034 口罩发放
团体程序设计天梯赛 L2-034 口罩发放题目链接为了抗击来势汹汹的 COVID19 新型冠状病毒,全国各地均启动了各项措施控制疫情发展,其中一个重要的环节是口罩的发放。某市出于给市民发放口罩的需要,推出了一款小程序让市民填写信息,方便工作的开展。小程序收集了各种信息,包括市民的姓名、身份证、身体情况、提交时间等,但因为数据量太大,需要根据一定规则进行筛选和处理,请你编写程序,按照给定规则输出口罩的寄送名单。输入格式:输入第一行是两个正整数 DDD 和 P(1≤D,P≤30)P(1≤D,P≤30)原创 2021-01-16 12:22:09 · 4517 阅读 · 1 评论 -
牛客编程巅峰赛S2第5场 - 钻石&王者 B.牛牛与后缀表达式
牛客编程巅峰赛S2第5场 - 钻石&王者 B.牛牛与后缀表达式题目链接题目描述给定牛牛一个后缀表达式s,计算它的结果,例如,1+1对应的后缀表达式为1#1#+,‘#’作为操作数的结束符号。其中,表达式中只含有‘+’、’-‘、’*‘三种运算,不包含除法。本题保证表达式一定合法,且计算过程和计算结果的绝对值一定不会超过10^{18}1018示例1输入"1#1#+"返回值2示例2输入"12#3#+15#*"返回值225简单栈操作,用一个数据栈存数字,用一个符号栈存原创 2020-12-01 21:26:20 · 2341 阅读 · 0 评论 -
2020 计蒜之道 预赛 第一场 A. 五子棋
2020 计蒜之道 预赛 第一场 A. 五子棋题目链接计蒜之道程序设计大赛已经迎来了第六届,蒜头君很开心,决定带上好友们一起下一把 五子棋,并由自己来担任裁判。五子棋的规则为:双方分别使用黑白两色的棋子,每次 落子(放置一个己方颜色的棋子),放在棋盘直线与横线的交叉点上,一方先形成至少五个己方颜色棋子连成一线者获胜。黑色棋子先手(第一个放置的棋子颜色一定是黑色)。在这里,没有任何禁手的限制(如果你不清楚禁手是什么,可以忽略这句话)。也就意味着,当一方出现六子连珠或更多己方棋子连成一条线时,也算这方胜原创 2020-09-12 22:25:06 · 2780 阅读 · 1 评论 -
牛客练习赛69 A.时间复杂度
牛客练习赛69 A.时间复杂度题目链接题目描述DK 想出一道超级没有素质的题DK 给了你一个标准的时钟,初始时间在 12:00每分钟分针会顺时针转动 6°,而时针会顺时针转动 0.5°DK 想知道,t 分钟后,时针和分针的较小夹角的大小是多少由于这题超级没有素质,所以你需要将答案四舍五入到整数输入描述:第一行一个整数 n,表示数据组数第 2 ~ n+1行,每行一个整数 t,意义见题目描述输出描述:输出n行,每行一个整数,表示答案示例1输入2180360输出90180原创 2020-09-12 09:44:33 · 2437 阅读 · 0 评论 -
牛客编程巅峰赛S1第11场 - 黄金&钻石 A.牛牛的01游戏
牛客编程巅峰赛S1第11场 - 黄金&钻石 A.牛牛的01游戏题目链接题目描述牛牛最近迷上了小游戏,于是他也想对他的01字符串进行一些操作,01字符串上的0和0相邻时会变成1,而1和1相邻时会在字符串上消失,而0和1相邻时什么都不会发生,牛牛现在把初始的字符串给你,你能告诉牛牛这个字符串最后会变成什么样吗。示例1输入"00110001"输出"01"简单模拟,就按题目要求来就行,注意一个坑点,两个 000 变成 111 后要判断答案字符串最后一位是否为 111,是的话直接删去即可原创 2020-08-14 09:10:46 · 2460 阅读 · 0 评论 -
牛客小白月赛1 F.三视图
牛客小白月赛1 F.三视图题目链接题目描述Etéreo 拿出家里的许多的立方体积木,堆成了一个三维空间中的模型。既然你高考选了技术, 那想必你一定想知道,这个模型的三视图是什么吧!图中,xx 轴、yy 轴和 zz 轴的方向已经标明。现在规定,图中的红色面为主视面,蓝色面为右视面(注意输出中应为左视而非右视),黄色面为俯视面。具体方向可以观察样例。输入描述:第一行四个数 X,Y,Z,N\mathbb{X}, \mathbb{Y}, \mathbb{Z}, \mathbb{N}X,Y,Z,N ,表原创 2020-08-12 10:42:40 · 2437 阅读 · 0 评论 -
HDUOJ 6816 Boring Game
HDUOJ 6816 Boring Game题目链接Problem DescriptionGiven n sheets of paper, place them on the table in pile and fold them in half k times from left to right.Now from top to bottom, mark a number on paper at each side of the front and back. So there are 2×n×2原创 2020-08-06 11:13:17 · 2331 阅读 · 0 评论 -
2020牛客暑期多校训练营(第七场)J.Pointer Analysis
2020牛客暑期多校训练营(第七场)J.Pointer Analysis题目链接题目描述Pointer analysis, which aims to figure out which objects accessible via a specific pointer variable in a program during the execution, is one of the fundamental parts of static program analysis. Now we want yo原创 2020-08-02 17:05:41 · 2513 阅读 · 0 评论 -
智算之道模拟赛 B.公交换乘
智算之道模拟赛 B.公交换乘题目链接【问题描述】著名旅游城市 B 市为了鼓励大家采用公共交通方式出行,推出了一种地铁换乘公交车的优惠方案:1.在搭乘一次地铁后可以获得一张优惠票,有效期为 45 分钟,在有效期内可以消耗这张优惠票,免费搭乘一次票价不超过地铁票价的公交车。在有效期内指开始乘公交车的时间与开始乘地铁的时间之差小于等于 45 分钟,即:2.搭乘地铁获得的优惠票可以累积,即可以连续搭乘若干次地铁后再连续使用优惠票搭乘公交车。3.搭乘公交车时,如果可以使用优惠票一定会使用优惠票;如果有多张原创 2020-07-09 10:38:36 · 2599 阅读 · 0 评论 -
2020 年 “联想杯”全国高校程序设计在线邀请赛暨第三届上海理工大学程序设计竞赛 H. Hay Mower
2020 年 “联想杯”全国高校程序设计在线邀请赛暨第三届上海理工大学程序设计竞赛 H. Hay Mower题目链接比较水的模拟题,设一个记录前次操作时间的数组即可,注意取模的问题,这题我用快速乘超时了,只能直接取模,方法就是尽量多取模,在能取模的地方都加上取模,你就过了????,AC代码如下:#include<bits/stdc++.h>using namespace std;typedef long long ll;const ll mod=998244353;int mai原创 2020-07-08 17:14:17 · 2437 阅读 · 0 评论 -
2019牛客暑期多校训练营(第八场)G.Gemstones
2019牛客暑期多校训练营(第八场)G.Gemstones题目链接题目描述Gromah and LZR have entered the seventh level. There are a sequence of gemstones on the wall.After some tries, Gromah discovers that one can take exactly three successive gemstones with the same types away from the原创 2020-07-07 15:07:14 · 2364 阅读 · 0 评论 -
LightOJ 1214 K - Large Division
LightOJ 1214 K - Large DivisionGiven two integers, a and b, you should check whether a is divisible by b or not. We know that an integer a is divisible by an integer b if and only if there exists an integer c such that a = b * c.InputInput starts with a原创 2020-07-04 20:38:37 · 2328 阅读 · 0 评论 -
团体程序设计天梯赛 L2-002 链表去重
团体程序设计天梯赛 L2-002 链表去重给定一个带整数键值的链表 L,你需要把其中绝对值重复的键值结点删掉。即对每个键值 K,只有第一个绝对值等于 K 的结点被保留。同时,所有被删除的结点须被保存在另一个链表上。例如给定 L 为 21→-15→-15→-7→15,你需要输出去重后的链表 21→-15→-7,还有被删除的链表 -15→15。输入格式:输入在第一行给出 L 的第一个结点的地址和...原创 2020-02-20 08:33:07 · 2719 阅读 · 0 评论 -
AtCoder Beginner Contest 170 E. Smart Infants
AtCoder Beginner Contest 170 E. Smart Infants考了一个高级数据结构~正好今天学了 multisetmultisetmultiset,所有的操作都是 O(logn),这题能够完美解决~用数组 mmm 记录每个幼儿园当前的最大排名,用 mxmxmx 记录所有幼儿园的最大排名,然后就是固定操作即可,AC代码如下:#include<bits/stdc++.h>using namespace std;typedef long long ll;co原创 2020-06-15 15:16:13 · 2412 阅读 · 0 评论 -
2019牛客暑期多校训练营(第三场)J.LRU management
2019牛客暑期多校训练营(第三场)J.LRU management题目描述ZYB has finished his computer course recently. He is very interested in the LRU algorithm for cache management.To simplify the problem, assume that a block contains a name (which is a string) and a set of data (whic原创 2020-06-22 14:58:49 · 2337 阅读 · 0 评论 -
东华大学2020年程序设计竞赛(同步赛)D.Moving stones
东华大学2020年程序设计竞赛(同步赛)D.Moving stones题目链接题目描述One day, GK was getting very bored with palying stones. So he made a rule for himself:There are n piles of stones in total, at least 0 stones in each pile. You can select a pile of stones each time you move, a原创 2020-06-07 21:13:18 · 2693 阅读 · 0 评论 -
Codeforces Round #598 (Div. 3) B.Minimize the Permutation
Codeforces Round #598 (Div. 3) B.Minimize the Permutation题目链接You are given a permutation of length n. Recall that the permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but原创 2020-05-26 16:33:41 · 2359 阅读 · 0 评论 -
第十五届中北大学算法与程序设计竞赛(公开赛)G.数位操作1
第十五届中北大学算法与程序设计竞赛(公开赛)G.数位操作1题目链接题目描述给你一个正整数 n(n<=1010)n (n<=10^{10} )n(n<=1010)找到最小的某个数据 ans (ans >9)要求 ans 的每一数位(个位 十位 百位 千位…) 乘积与 n 相等, 不存在输出-1PS:多组输入,输入直到文件结束输入描述:输入一个小于等于 101010^{10}1010 的数正整数n输出描述:如果可以找到 某个数据 ans 数位乘积与 n 相等 那么便输原创 2020-05-24 20:47:12 · 2324 阅读 · 0 评论 -
Codeforces Round #640 (Div. 4) D. Alice, Bob and Candies
Codeforces Round #640 (Div. 4) D. Alice, Bob and Candies题目链接There are n candies in a row, they are numbered from left to right from 1 to n. The size of the i-th candy is ai.Alice and Bob play an interesting and tasty game: they eat candy. Alice will eat原创 2020-05-13 11:11:47 · 2482 阅读 · 0 评论 -
Codeforces Round #639 (Div. 2) C.Hilbert‘s Hotel
Codeforces Round #639 (Div. 2) C.Hilbert’s Hotel题目链接Hilbert’s Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zer...原创 2020-05-07 10:39:33 · 2343 阅读 · 0 评论 -
Codeforces Round #632 (Div. 2) B.Kind Anton
Codeforces Round #632 (Div. 2) B.Kind Anton题目链接Once again, Boris needs the help of Anton in creating a task. This time Anton needs to solve the following problem:There are two arrays of integers a ...原创 2020-04-09 10:38:44 · 2247 阅读 · 0 评论 -
AtCoder Beginner Contest 161 E.Yutori
AtCoder Beginner Contest 161 E.Yutori题目链接Problem StatementTakahashi has decided to work on K days of his choice from the N days starting with tomorrow.You are given an integer C and a string S. Ta...原创 2020-04-05 11:09:57 · 3963 阅读 · 0 评论 -
AtCoder Beginner Contest 161 D.Lunlun Number
AtCoder Beginner Contest 161 D.Lunlun Number题目链接Problem StatementA positive integer X is said to be a lunlun number if and only if the following condition is satisfied:In the base ten representati...原创 2020-04-05 09:37:29 · 2575 阅读 · 0 评论 -
Codeforces Round #631 (Div. 2) B.Dreamoon Likes Permutations
Codeforces Round #631 (Div. 2) B.Dreamoon Likes Permutations题目链接The sequence of m integers is called the permutation if it contains all integers from 1 to m exactly once. The number m is called the ...原创 2020-04-04 11:37:38 · 2500 阅读 · 0 评论 -
Codeforces Round #629 (Div. 3) C.Ternary XOR
Codeforces Round #629 (Div. 3) C.Ternary XORA number is ternary if it contains only digits 0, 1 and 2. For example, the following numbers are ternary: 1022, 11, 21, 2002.You are given a long ternary...原创 2020-03-27 08:51:13 · 2376 阅读 · 0 评论 -
Educational Codeforces Round 83 (Rated for Div. 2) C.Adding Powers
Educational Codeforces Round 83 (Rated for Div. 2) C.Adding PowersSuppose you are performing the following algorithm. There is an array v1,v2,…,vn filled with zeroes at start. The following operation...原创 2020-03-10 19:40:33 · 2329 阅读 · 0 评论 -
CodeCraft-20 (Div. 2) B.String Modification
CodeCraft-20 (Div. 2) B.String ModificationVasya has a string s of length n. He decides to make the following modification to the string:Pick an integer k, (1≤k≤n).For i from 1 to n−k+1, reverse th...原创 2020-03-06 08:46:27 · 2247 阅读 · 0 评论 -
Ozon Tech Challenge 2020 B.Kuroni and Simple Strings
Ozon Tech Challenge 2020 B.Kuroni and Simple Strings题目链接Now that Kuroni has reached 10 years old, he is a big boy and doesn’t like arrays of integers as presents anymore. This year he wants a Bracke...原创 2020-03-04 15:58:33 · 2308 阅读 · 0 评论 -
洛谷P3015 [USACO11FEB] Best Parenthesis
洛谷P3015 Best Parenthesis题目描述Recently, the cows have been competing with strings of balanced parentheses and comparing them with each other to see who has the best one.Such strings are scored as fol...原创 2020-03-02 17:00:19 · 2498 阅读 · 0 评论 -
AtCoder Beginner Contest 157 C.Guess The Number
AtCoder Beginner Contest 157 C.Guess The Number题目链接Problem StatementIf there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print -1....原创 2020-03-02 08:54:31 · 2876 阅读 · 3 评论 -
牛客小白月赛22 A.操作序列
牛客小白月赛22 A.操作序列题目描述给出一个长度无限的数列,初始全部为零,有三种操作:增加操作:给下标为 tt 的数加 cc 。特别注意,如果在下标 [t−30,t+30][t-30,t+30][t−30,t+30]内有不为零的数,增加操作无效。削减操作:让数列中下标最小的不为零数变为零。查询操作:查询数列中下标为 t 的数字是多少。输入描述:第一行包含一个整数 N,1≤N≤106...原创 2020-02-23 15:07:07 · 2773 阅读 · 1 评论 -
Codeforces Round #619 (Div. 2) B.Motarack's Birthday
Codeforces Round #619 (Div. 2) B.Motarack’s BirthdayDark is going to attend Motarack’s birthday. Dark decided that the gift he is going to give to Motarack is an array a of n non-negative integers.D...原创 2020-02-19 16:18:16 · 2814 阅读 · 0 评论 -
PAT甲级 1025 PAT Ranking
PAT甲级 1025 PAT RankingProgramming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several plac...原创 2020-02-17 16:00:06 · 2633 阅读 · 0 评论 -
POJ 2826 An Easy Problem?!
POJ 2826 An Easy Problem?!DescriptionIt’s raining outside. Farmer Johnson’s bull Ben wants some rain to water his flowers. Ben nails two wooden boards on the wall of his barn. Shown in the pictures ...原创 2020-02-17 12:39:43 · 2784 阅读 · 0 评论 -
AtCoder Beginner Contest 155 E.Payment
AtCoder Beginner Contest 155 E.PaymentProblem StatementIn the Kingdom of AtCoder, only banknotes are used as currency. There are10100+110^{100}+110100+1 kinds of banknotes, with the values of 1,10,...原创 2020-02-17 08:19:19 · 2924 阅读 · 0 评论 -
2020牛客寒假算法基础集训营4 E.最小表达式
2020牛客寒假算法基础集训营4 E.最小表达式题目描述给出一个包含数字1-9和加号的字符串,请你将字符串中的字符任意排列,但每种字符数目不变,使得结果是一个合法的表达式,而且表达式的值最小。输出那个最小表达式的值合法的表达式的定义如下:一个数字,如233,是一个合法的表达式A + B是合法的表达式,当且仅当 A , B 都是合法的表达式保证给出的表达式经过重排,存在一个合...原创 2020-02-12 15:55:16 · 2692 阅读 · 0 评论