
做题笔记和反思
文章平均质量分 72
做题笔记和反思
在?为什么不学习
满堂花醉三千客,一剑寒霜十四洲
展开
-
2022下半年一些有趣(bushi)的题目记录
ACM题目原创 2022-07-11 20:56:03 · 266 阅读 · 0 评论 -
一些因吹斯汀的题目记录
组合数学——隔板法离散化 + 树状数组组合数学——隔板法题:https://ac.nowcoder.com/acm/contest/30184/L题意:给出每个数在 1~1000 之间的单调不增序列,其中有一些数字丢失了,找出有多少方案满足该序列要求,答案对1000000007取模。#include <iostream>#include <cstdio>#include <queue>#include <deque> #include <.原创 2022-03-22 02:06:14 · 980 阅读 · 0 评论 -
关于做算法题中比较粗心的一些点记录。
看错题(某道题输入看错了wa了一晚上我也是吐了orz)多个测试数据忘记初始化(这个错也是很经典了hhhh)遍历匹配子串的时候算错了,最后一个字母没遍历就break了(憨批.jpg)原创 2022-03-08 20:31:47 · 122 阅读 · 0 评论 -
寒假练习题
https://ac.nowcoder.com/acm/problem/14595原创 2022-01-06 20:28:38 · 151 阅读 · 0 评论 -
省赛练习题
Maximal submatrixGiven a matrix of n rows and m columns,find the largest area submatrix which is non decreasing on each columnInputThe first line contains an integer T(1≤T≤10)representing the number of test cases.For each test case, the first line cont原创 2021-09-25 18:34:28 · 127 阅读 · 0 评论 -
Benelux Algorithm Programming Contest 2020(牛客网) 补题
B - Balanced BreakdownB - Balanced BreakdownFor communication through space between earth and satellites, one cannot simply transmit a message in the same way as cellular communication like 4G. Because of the extremely long distance a signal travels, th.原创 2021-08-02 17:14:32 · 149 阅读 · 0 评论 -
B. Pleasant Pairs
You are given an array a1,a2,…,an consisting of n distinct integers. Count the number of pairs of indices (i,j) such that i<j and ai⋅aj=i+j.InputThe first line contains one integer t (1≤t≤10^4) — the number of test cases. Then t cases follow.The firs原创 2021-06-28 13:29:00 · 773 阅读 · 4 评论 -
B. Prinzessin der Verurteilung
I, Fischl, Prinzessin der Verurteilung, descend upon this land by the call of fate an — Oh, you are also a traveler from another world? Very well, I grant you permission to travel with me.It is no surprise Fischl speaks with a strange choice of words. How转载 2021-06-09 11:35:15 · 290 阅读 · 0 评论 -
C. Division
Oleg’s favorite subjects are History and Math, and his favorite branch of mathematics is division.To improve his division skills, Oleg came up with t pairs of integers pi and qi and for each pair decided to find the greatest integer xi, such that:pi is d原创 2021-06-01 21:39:45 · 643 阅读 · 1 评论 -
C. Balance the Bits
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters ‘+’ and ‘1’. For example, sequences ‘(())()’, ‘()’, and ‘(()(()))’ are balanced, while ‘)(’, ‘(()’, and ‘(()))(’ are not.You are given a binary原创 2021-05-24 18:07:30 · 281 阅读 · 1 评论 -
二分法做题记录
题:陶陶是个贪玩的孩子,他在地上丢了A个瓶盖,为了简化问题,我们可以当作这A个瓶盖丢在一条直线上,现在他想从这些瓶盖里找出B个,使得距离最近的2个距离最大,他想知道,最大可以到多少呢?输入格式第一行,两个整数,A,B(2≤B≤A≤10^5)。第二行,A个整数,分别为这A个瓶盖坐标,在[1,10^9]范围内。输出格式仅一个整数,为所求答案。Sample Input5 31 2 3 4 5Sample Output2思路:二分法首先,排序,然后固定选第一个瓶盖。由题知,B大于等于二原创 2021-05-17 14:44:57 · 188 阅读 · 0 评论 -
D. Maximum Sum of Products
题:You are given two integer arrays a and b of length n.You can reverse at most one subarray (continuous subsegment) of the array a.Your task is to reverse such a subarray that the sumis maximized.InputThe first line contains one integer n (1≤n≤5000)转载 2021-05-10 20:32:34 · 307 阅读 · 0 评论 -
D. Same Differences && B. Interesting Subarray
题:You are given an array a of n integers. Count the number of pairs of indices (i,j) such that i<j and aj−ai=j−i.InputThe first line contains one integer t (1≤t≤10^4). Then t test cases follow.The first line of each test case contains one integer n原创 2021-05-07 17:08:40 · 389 阅读 · 0 评论 -
DFS(深度优先搜索)做题记录
DFS(深度优先搜索)做题记录P1030 [NOIP2001 普及组] 求先序排列P1036 [NOIP2002 普及组] 选数P1030 [NOIP2001 普及组] 求先序排列题目描述给出一棵二叉树的中序与后序排列。求出它的先序排列。(约定树结点用不同的大写字母表示,长度\le 8≤8)。输入格式22行,均为大写字母组成的字符串,表示一棵二叉树的中序与后序排列。输出格式11行,表示一棵二叉树的先序。样例输入BADCBDCA输出ABCD思路:中序:左-根-右后序:左-右-根原创 2021-05-04 23:18:33 · 361 阅读 · 1 评论 -
C. Phoenix and Towers
题Phoenix has n blocks of height h1,h2,…,hn, and all hi don’t exceed some value x. He plans to stack all n blocks into m separate towers. The height of a tower is simply the sum of the heights of its blocks. For the towers to look beautiful, no two towers转载 2021-05-04 01:23:56 · 237 阅读 · 0 评论 -
C. Berland Regional
题:Polycarp is an organizer of a Berland ICPC regional event. There are n universities in Berland numbered from 1 to n. Polycarp knows all competitive programmers in the region. There are n students: the i-th student is enrolled at a university ui and has转载 2021-05-02 18:21:20 · 354 阅读 · 0 评论 -
B. AGAGA XOOORRR
题:Baby Ehab is known for his love for a certain operation. He has an array a of length n, and he decided to keep doing the following operation on it:he picks 2 adjacent elements; he then removes them and places a single integer in their place: their bitw原创 2021-04-29 22:12:00 · 369 阅读 · 1 评论 -
B. Morning Jogging
题:The 2050 volunteers are organizing the “Run! Chase the Rising Sun” activity. Starting on Apr 25 at 7:30 am, runners will complete the 6km trail around the Yunqi town.There are n+1 checkpoints on the trail. They are numbered by 0, 1, …, n. A runner must转载 2021-04-28 13:14:42 · 345 阅读 · 0 评论 -
2021.4.10月赛题解
A -火柴棒不等式题:给你n根火柴棍,你可以拼出多少个形如“A+B=C”的等式?等式中的A、B、C是用火柴棍拼出的整数(若该数非零,则最高位不能是0)。用火柴棍拼数字0-9的拼法如图所示:注意:加号与等号各自需要两根火柴棍如果A≠B 则A+B=C与B+A=C视为不同的等式(A,B,C>=0)n根火柴棍必须全部用上输入一个正整数n, 1<=n<=24输出一个整数,能拼成的不同等式的数目样例输入:18样例输出:9ps:本来以为是道益智题,没想到是简单暴力em原创 2021-04-22 01:16:06 · 1476 阅读 · 1 评论 -
2017蓝桥杯:包子凑数
题小明几乎每天早晨都会在一家包子铺吃早餐。这家包子铺有N种蒸笼,其中第i种蒸笼恰好能放Ai个包子每种蒸笼都有非常多笼,可以认为是无限笼。每当有顾客想买X个包子,卖包子的大叔就会选出若干笼包子来,使得这若干笼中恰好一共有X个包子。比如一共有3种蒸笼,分别能放3、4和5个包子。当顾客想买11个包子时,大叔就会选2笼3个的再加1笼5个的(也可能选出1笼3个的再加2笼4个的)。当然有时包子大叔无论如何也凑不出顾客想买的数量。比如一共有3种蒸笼,分别能放4、5和6个包子。而顾客想买7个包子时,大叔就凑不出转载 2021-04-16 21:19:40 · 79 阅读 · 0 评论 -
2017蓝桥杯:日期问题
题:小明正在整理一批历史文献。这些历史文献中出现了很多日期。小明知道这些日期都在1960年1月1日至2059年12月31日。令小明头疼的是,这些日期采用的格式非常不统一,有采用年/月/日的,有采用月/日/年的,还有采用日/月/年的。更加麻烦的是,年份也都省略了前两位,使得文献上的一个日期,存在很多可能的日期与其对应。比如02/03/04,可能是2002年03月04日、2004年02月03日或2004年03月02日。给出一个文献上的日期,你能帮助小明判断有哪些可能的日期对其对应吗?输入一个日期转载 2021-04-16 19:59:45 · 114 阅读 · 0 评论 -
2020蓝桥杯:回文日期
题:2020 年春节期间,有一个特殊的日期引起了大家的注意:2020 年 2 月 2 日。因为如果将这个日期按 “yyyymmdd” 的格式写成一个 8 位数是 20200202,恰好是一个回文数。我们称这样的日期是回文日期。有人表示 20200202 是“千年一遇” 的特殊日子。对此小明很不认同,因为不到 2 年之后就是下一个回文日期:20211202 即 2021 年 12 月 2 日。也有人表示 20200202 并不仅仅是一个回文日期,还是一个 ABABBABA 型的回文日期。对此小明转载 2021-04-15 20:55:27 · 527 阅读 · 0 评论 -
C. Yet Another Card Deck
题:You have a card deck of n cards, numbered from top to bottom, i. e. the top card has index 1 and bottom card — index n. Each card has its color: the i-th card has color ai.You should process q queries. The j-th query is described by integer tj. For eac原创 2021-04-13 16:02:06 · 213 阅读 · 0 评论 -
2020蓝桥杯试题C:蛇形填数
【问题描述】如下图所示,小明用从 1 开始的正整数“蛇形”填充无限大的矩阵。1 2 6 7 15 …3 5 8 14 …4 9 13 …10 12 …11 … … 容易看出矩阵第二行第二列中的数是 5。请你计算矩阵中第 20 行第 20列 的数是多少?【答案提交】这是一道结果填空的题,你只需要算出结果后提交即可。本题的结果为一个整数,在提交答案时只填写这个整数,填写多余的内容将无法得分。去年大概是十二月份左右在洛谷上刷到过这题,当时太菜了没写出来,然后过2020蓝桥杯题的时候又刷到了.原创 2021-04-09 17:44:56 · 784 阅读 · 1 评论 -
(交互题)Searching Local Minimum
题:This is an interactive problem.Homer likes arrays a lot and he wants to play a game with you.Homer has hidden from you a permutation a1,a2,…,an of integers 1 to n. You are asked to find any index k (1≤k≤n) which is a local minimum.For an array a1,a2,原创 2021-02-08 23:28:18 · 471 阅读 · 1 评论 -
P1075 [NOIP2012 普及组] 质因数分解
思路:约数是成对出现的(平方数除外)也就是说,一个数的第一小约数乘第一大约数相乘等于这个数,第二小约数乘第二大约数相乘也依然等于这个数!因此,只要找出n的最小约数(1除外),再用n除以这个数,就能得到结果了!#include<iostream>#include<cmath>using namespace std;int B[10005][5];int main(){ long n; cin>>n; for(int i=2;i<=n;++.原创 2021-02-05 20:40:45 · 285 阅读 · 0 评论 -
P1003 [NOIP2011 提高组] 铺地毯
题:思路:这题的意思是要输出覆盖在最上面的地毯的编号,所以可以从后往前遍历,创一个数组去存数据,然后判断要求的那个坐标在不在地毯范围内,在的话就输出地毯编号,否则输出-1。注:这题之前犯了一个很蠢的错误,就是开了二维数组去存平面,然后一个个去遍历加一,虽然样例答案算出来是对的,但是很明显会超时超内存。#include<iostream>using namespace std;int B[10005][5];int main(){ int t; cin>>原创 2021-02-05 20:22:24 · 96 阅读 · 0 评论 -
Palindromes
题:A regular palindrome is a string of numbers or letters that is the same forward as backward. Forexample, the string “ABCDEDCBA” is a palindrome because it is the same when the string is read fromleft to right as when the string is read from right to l原创 2021-01-31 01:53:21 · 144 阅读 · 0 评论 -
Repeating Decimals
题:The decimal expansion of the fraction 1/33 is 0.03, where the 03 is used to indicate that the cycle 03repeats indefinitely with no intervening digits. In fact, the decimal expansion of every rational number(fraction) has a repeating cycle as opposed t原创 2021-01-30 19:39:41 · 201 阅读 · 0 评论 -
Find The Array
You are given an array [????1,????2,…,????????] such that 1≤????????≤109. Let ???? be the sum of all elements of the array ????.Let’s call an array ???? of ???? integers beautiful if:1≤????????≤109 for each ???? from 1 to ????;for every pair of adjacent原创 2021-01-22 16:58:48 · 258 阅读 · 0 评论 -
Fair Numbers
B. Fair Numberstime limit per test2 secondsmemory limit per test256 megabytesWe call a positive integer number fair if it is divisible by each of its nonzero digits. For example, 102102 is fair (because it is divisible by 11 and 22), but 282282 is not,原创 2020-12-24 02:08:41 · 294 阅读 · 0 评论 -
A Cookie for You
A Cookie for YouAnna is a girl so brave that she is loved by everyone in the city and citizens love her cookies. She is planning to hold a party with cookies. Now she has a vanilla cookies and b chocolate cookies for the party.She invited n guests of the原创 2020-12-22 20:45:42 · 224 阅读 · 1 评论