自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(16)
  • 收藏
  • 关注

原创 子矩阵求和(二维前缀和)

题目给出一个行列的矩阵,矩阵第行第列一个非负整数,有次询问,每次询问求一个左上角为,右下角为的子矩阵的所有数之和。

2023-05-20 22:44:25 200

原创 D同余方程

题目求关于xx的同余方程ax \equiv 1 \pmod{b}ax≡1(modb)的最小正整数解。思路利用欧几里得算法即可求解,注意结果为负是要取余再加模代码#include<iostream>#include<stdio.h>using namespace std;int exgcd(int a, int b, int &x, int &y){ if(b == 0) {x=1, y=0; return a;} i...

2022-03-09 10:57:48 116

原创 LibreOJ 2060 食物链

题目现在给你 nn 个物种和 mm 条能量流动关系,求其中的食物链条数。物种的名称为从 11 到 nn 的编号。mm 条能量流动关系形如a_1a1​b_1b1​a_2a2​b_2b2​a_3a3​b_3b3​… …a_mam​b_mbm​其中 a_i \ b_iai​ bi​ 表示能量从物种 a_iai​ 流向物种 b_ibi​。注意单独的一种孤立生物不算一条食物链。输入第一行两个整数 nn 和 mm,接下来 mm 行每行两个整数 a_i \ b_iai​ b...

2022-03-09 10:55:27 202

原创 计蒜客T1320 子矩阵求和

题目给出一个nn行mm列的矩阵,矩阵的每个位置有一个非负整数a[i][j]a[i][j],有qq次询问,每次询问求一个左上角为(a,b)(a,b),右下角为(c,d)(c,d)的子矩阵的所有数之和。输入格式第一行两个整数n,mn,m,表示矩阵的行和列的大小。接下来nn行每行mm个整数,为矩阵内容。接下来一行为一个整数qq,表示询问次数。接下来qq行每行44个整数a,b,c,da,b,c,d,含义见题面。输出格式共qq行,第ii...

2022-03-09 10:50:32 597 1

原创 POJ 2828 Buy Tickets

题目Railway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and join a long queue…The Lunar New Year was approaching, but unluckily the Little Cat still had schedules going here and there. Now, he had to travel b

2022-03-09 10:47:54 107

原创 POJ 2528 Mayor‘s posters

题目The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city council has finally decided to build an electoral wall for placing the po

2022-03-09 10:44:39 99

原创 POJ 2777 Count Color

题目Chosen Problem Solving and Program design as an optional course, you are required to solve all kinds of problems. Here, we get a new problem.There is a very long board with length L centimeter, L is a positive integer, so we can evenly divide the boar

2022-03-07 09:48:41 57

原创 POJ 2182 Lost Cow

题目N (2 <= N <= 8,000) cows have unique brands in the range 1..N. In a spectacular display of poor judgment, they visited the neighborhood 'watering hole' and drank a few too many beers before dinner. When it was time to line up for their evening me

2022-03-07 09:45:14 161

原创 Fedya and Maths

题目思路通过找规律可以发现答案其实是五个一循环,因此只需判断n是否为4的倍数代码#include<stdio.h>#include<string.h>char num[100005];int main(){ scanf("%s", num); int a = 0; if(strlen(num) == 1) { a = num[0] - '0'; } else if(strlen(num) >= 2) { in.

2022-03-07 09:40:33 57

原创 k-rounding

题目For a given positive integer n denote its k-rounding as the minimum positive integer x, such that x ends with k or more zeros in base 10 and is divisible by n.For example, 4-rounding of 375 is 375·80 = 30000. 30000 is the minimum integer such that it

2022-03-07 09:36:53 53

原创 CodeForces 277A Learning Language

题目The "BerCorp" company has gotnemployees. These employees can usemapproved official languages for the formal correspondence. The languages are numbered with integers from1tom. For each employee we have the list of languages, which he knows. This ...

2022-03-07 09:31:29 76

原创 LibreOj 109 并查集

题目维护一个nn点的无向图,支持:加入一条连接uu和vv的无向边 查询uu和vv的连通性由于本题数据较大,因此输出的时候采用特殊的输出方式:用00或11代表每个询问的答案,将每个询问的答案依次从左到右排列,把得到的串视为一个二进制数,输出这个二进制数mod998244353的值。请务必使用快读。思路这是一道并查集的模板题,注意输入输出的时候不要用cin, count;代码#include<iostream>#includ...

2022-03-07 09:26:17 99

原创 计蒜客T1224 开餐馆

题目蒜头君想开家餐馆. 现在共有 nn 个地点可供选择。蒜头君打算从中选择合适的位置开设一些餐馆。这 nn 个地点排列在同一条直线上。我们用一个整数序列 m_1, m_2, ... m_nm1​,m2​,...mn​ 来表示他们的相对位置。由于地段关系, 开餐馆的利润会有所不同。我们用 p_ipi​ 表示在 m_imi​ 处开餐馆的利润。为了避免自己的餐馆的内部竞争,餐馆之间的距离必须大于 kk。请你帮助蒜头君选择一个总利润最大的方案。输入格式标准的输入包含若干组测试数据。输入第一行

2022-03-07 09:21:53 250

原创 计蒜客T2129 采药

题目思路此题用动态规划,对于每一件药品都有采和不采两种选择,因此可以推出递归式:dp[i][j] = max(dp[i+1][j-t[i]]+v[i], dp[i+1][j])其中i是是第i个物品, j表示剩余时间, v表示药品价值, t表示花费的时间。并且每次采摘前都得保证剩余时间足够。代码#include<stdio.h>#include<string.h>using namespace std;int time[1000], val

2022-03-07 09:09:45 414

原创 计蒜客T1738 地毯

题目思路开一个全为0的数组,对于每个地毯,将左上角的坐标+1, 右下角右边和下边的坐标-1,最后再做一次前缀和。代码#include<iostream>#include<stdio.h>#include<string.h>using namespace std;int ground[1003][1003];int main(){ memset(ground, 0, sizeof(ground)); int n, m; in

2022-03-07 08:57:58 194 1

原创 POJ1979 Red and Black

题目There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles

2022-03-07 08:50:59 62

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除