自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 leetcode——715. Range 模块

题目链接线段树加动态开点const int N=1e6+500;const int M=1e9;struct tree { int l,r; int data,lazy;#define l(p) t[p].l#define r(p) t[p].r#define data(p) t[p].data#define lazy(p) t[p].lazy} t[N];class RangeModule { public: int tot,root; RangeModule() {

2021-01-02 20:54:48 177

原创 第 45 届国际大学生程序设计竞赛(ICPC)亚洲区域赛(上海)——I

Sky Garden#include<bits/stdc++.h>#define pi acos(-1.0)using namespace std;typedef long long ll;typedef double db;const int N=1005;db anlen[N];int main() { int n,m; scanf("%d %d",&n,&m); db ans=0; int dian=m*2; int a=floor((1.0/p

2020-12-18 16:47:47 722 1

原创 2019 TCO Regional Event 现场热身游戏

Simple Billiards题目链接二维 xOy 平面内放置着一张 w×h 的长方形台球桌。球桌左下角的坐标是 (0,0)、右上角的坐标是 (w,h),并且每个角都开有一个球袋。现在有一颗初始位于球桌内部 (x,y) 位置的球沿 Ox 逆时针旋转 r 度的方向被击出。当球碰到球桌边缘(但不是球桌的角)时,会遵循反射定律反弹回去,然后在球桌上继续前进直到碰到球桌的某个角并落入球袋。你需要判断这颗球最终是否会落入某个球袋中。为了简化问题,球和每个球袋都会被看作是一个点,球能落袋当且仅当某时刻球的位置

2020-12-11 22:22:27 192

原创 2019ICPC南京——H

Prince and Princess题目链接麻婆王子与豆腐公主。。。给定三个数 a ,b,ca个人说真话b个人说假话c个人可能说真话可能说假话可以询问的三个问题1.你是谁?2.某个房子里住着谁?3.公主在那个房间?问 询问多少次 可以确定公主在哪个房间。题解:只考虑问第三个问题,统计每个人的回答,b和c都说假话,只要有b+c+1个人说真话,就会有一个答案被统计的次数超过说假话的人。注意特判一下 只有一个公主的情况。#include<bits/stdc++.h>

2020-12-10 18:07:43 376

原创 2019ICPC南京——K

Triangle题目链接给定一个三角形,和三角形上一个点,求三角形上另一个点,两点将三角形分成面积均等的两份。利用比值的思想,即可求解。#include<bits/stdc++.h>using namespace std;typedef long long ll;typedef double db;ll x1,x2,x3,y11,y2,y3,x,y;bool check(ll x1,ll y11,ll x2,ll y2,ll x,ll y) {//判断给定点是不是在三角形

2020-12-10 17:58:38 321

原创 Wannafly挑战赛5——D

子序列从m个位置中选出n个位置,每个位置有26种选择,这样就会出现重复的情况,例如题中的样例,按照这种方法,答案就是52。a_ _ b_ _ c_ _ _ ,a与b之间不能为a,b与c之间不能为b,所以,前面的空有25种选择方式,后面的空有26种选择方式,所以,只需要枚举字符串最后一位的位置,答案为C(i-1,n-1)*25(i-n)*26(m-i)相加的和。#include<bits/stdc++.h>using namespace std;typedef long long ll

2020-12-08 16:03:01 104

原创 Wannafly挑战赛5——A

珂朵莉与宇宙一道挺简单的思维题,想了好久没想出来,写个博客记录一下。#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=1e6+600;int vis[N];int main() { int n; scanf("%d",&n); int cut=0; vis[cut]++; ll ans=0; for(int i=1; i<=n; ++i) {

2020-12-08 11:44:38 83

原创 2020CCPC绵阳站——J

Joy of Handcraft题意:一串灯泡,每个灯泡都有一个亮度,一个开关周期,问每秒最亮的灯度是多少。题解:相同开关周期的灯泡,同时关,同时开,所以同一周期的灯泡,只需要考虑亮度最高的那个即可,其余灯泡对答案没影响。每一秒过后,周期为该秒数的因子的灯会变换一次状态,1e5以内的数,最多有120+个因子,所以,每秒最多只需要修改120+个等的状态即可。我们可以用线段树维护每种周期灯的状态,节点维护区间最大值,每次查询答案,只需要看根节点的值即可。#include<bits/stdc++

2020-11-04 21:13:30 837

原创 洛谷——P6298 齿轮

题目描述Daniel13265 从不知哪里找来了 nn 个齿轮,第 ii 个齿轮的齿数为不超过 mm 的正整数 a_iai​ 。他现在想把其中 kk 个齿轮按照一定的方式拼接在一起。当齿轮使用一段时间后,就会产生损耗。一个齿轮组的损耗速率是由这个齿轮组的所有齿轮齿数的最大公约数决定的:最大公约数越大,相同的齿之间啮合的频率就会增高,从而损耗的速率就会变快。这个最大公约数又被称为损耗因子。算出一个齿轮组的损耗因子是很容易的。可是现在 Daniel13265 想要知道,对于可能拼接出的所有齿轮组的损

2020-10-10 16:23:51 153

原创 牛客练习赛71——C.数学考试

时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述牛牛在树剖姐姐的数学考试里出了一个题,但是树剖姐姐不会做,于是她向您求助。求 1\sim n1∼n 的排列,有 m 个限制条件,第i个限制条件 p_ipi​ 表示前 p_ipi​ 个数不能是 1\sim p_i1∼pi​ 的排列,求符合要求的排列的个数。答案对 20000311 取模。输入描述:第一行两个 n,m第二行 m

2020-10-10 09:51:28 349

原创 快速傅里叶变换(FFT)

洛谷模板题大佬博客1大佬博客2留个板子,供以后用#include<iostream>#include<cmath>#include<cstdio>#include<cstring>using namespace std;typedef long long ll;const int N=4e6+500;const double PI=acos(-1.0);int n,m,limit=1,l,r[N];struct complex {

2020-09-28 20:49:13 152

原创 序列自动机

一道CF的简单例题题目链接nex数组记录第i个位置后j第一次出现的位置。#include<bits/stdc++.h>using namespace std;const int N=2e5+500;string a;string b;int nex[N][30];int main() { cin>>a; //序列自动机代码 int n=a.size(); for(int i=n; i>0; i--) { for(int j=0; j<26;

2020-09-19 14:43:49 111

原创 洛谷——P1456 Monkey King

题目描述Once in a forest, there lived N aggressive monkeys. At the beginning, they each does things in its own way and none of them knows each other. But monkeys can’t avoid quarrelling, and it only happens between two monkeys who does not know each other. An

2020-09-19 11:22:07 306

原创 洛谷——P4198 楼房重建

题目描述小 A 的楼房外有一大片施工工地,工地上有 NN 栋待建的楼房。每天,这片工地上的房子拆了又建、建了又拆。他经常无聊地看着窗外发呆,数自己能够看到多少栋房子。为了简化问题,我们考虑这些事件发生在一个二维平面上。小 A 在平面上 (0,0)(0,0) 点的位置,第 ii 栋楼房可以用一条连接 (i,0)(i,0) 和 (i,H_i)(i,Hi​ ) 的线段表示,其中 H_iHi​ 为第 ii 栋楼房的高度。如果这栋楼房上任何一个高度大于 00 的点与 (0,0)(0,0) 的连线没有与

2020-09-14 22:14:43 220

原创 2020牛客暑期多校训练营(第九场)——E

Groundhog Chasing Death链接:https://ac.nowcoder.com/acm/contest/5674/E来源:牛客网时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述As we all know,“Groundhog chasing death” means “GCD”,while “GCD” stands for “greatest common divisor

2020-09-08 21:26:38 167

原创 CF——501D(变进制数康托展开)

D. Misha and Permutations Summationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet’s define the sum of two permutations p and q of numbers 0, 1, …, (n - 1) as permutation , where Perm(x) is the

2020-08-23 18:20:17 135

原创 2020牛客暑期多校训练营(第八场)—— K

Kabaleo Lite链接:https://ac.nowcoder.com/acm/contest/5673/K来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述Tired of boring WFH (work from home), Apollo decided to open a fast food restaurant, called \textbf{Kabaleo Lit

2020-08-05 22:42:32 279

原创 牛客——等级之题 N1(8.3)

链接:https://ac.nowcoder.com/acm/contest/6766/A来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld题目描述有一个箱子,开始时有n个黑球,m个蓝球。每一轮游戏规则如下:第一步:奕奕有p的概率往箱子里添加一个黑球,有(1-p)的概率往箱子里添加一个蓝球。第二步:华华随机从箱子里取出一个球。华华喜欢黑球,他想知道k轮游戏之后箱子里黑球个数的期望。输

2020-08-05 22:39:09 320

原创 整除分块板子

#include<bits/stdc++.h>using namespace std;typedef long long ll;const ll mod=1e9+7;ll zcfk(ll n,ll k) { if(k>=n) { ll cut=0; for(ll l=2,r; l<=n; l=r+1) { r=n/(n/l); cut=(cut+1ll*(r-l+1)*(n/l)%mod)%mod; } return cut; } else {

2020-08-01 15:28:29 145

原创 二维线段树

二维数组,稍微学了一下,写个博客,留个板子,日后忘了看。HDU——4819#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=1005;int maxx[N*4][N*4],minn[N*4][N*4],a[N][N];int n,m,Mx,Mi;void pushup(int px,int py) { maxx[px][py]=max(maxx[px][py*2],maxx[p

2020-07-26 00:03:31 190 1

原创 2020牛客暑期多校训练营(第四场)——H

Harder Gcd Problem时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288KSpecial Judge, 64bit IO Format: %lld题目描述After solving the Basic Gcd Problem, ZYB gives you a more difficult one:Given an integer n{n}n, find two subset A{A}A and B{B}B of {1,2,…,n}{1

2020-07-20 23:34:06 205

原创 2020牛客暑期多校训练营(第三场)——F

Fraction Construction Problem题目描述There are t queries.In each query, you are given two positive integers a and b (a, b \le 2 \times 10^6a,b≤2×106).Please print a line consists of four positive integers c,d,e,f satisfying the following constraints:• \fr

2020-07-19 22:13:47 657

原创 EOJ Monthly 2020.7 Sponsored by TuSimple——E

因数串很少能遇到这种用到基础数论知识的题,写篇博客复习一下。首先,输入的n对数,是将这个数进行质因数分解的结果,任何一个大于1的正整数都能唯一分解为有限个质数的乘积,可写作:N=p1c1p2c2p3c3…pmcm其中pi都是质数,其p1<p2<p3…<pm。一个数的因子个数为:(c1+1)(c2+1)(c3+1)…*(cm+1)#include<bits/stdc++.h>using namespace std;typedef long long ll;ll

2020-07-17 23:56:14 401

原创 2020牛客暑期多校训练营(第二场)——K

Keyboard Free链接:https://ac.nowcoder.com/acm/contest/5667/K来源:牛客网时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述Given three concentric circles whose radiuses are r_1, r_2, r_3r1​,r2​,r3​ respectively, and {A,B,C}A,B,C are

2020-07-17 16:29:20 278

原创 2020牛客暑期多校训练营(第二场)——A

All with Pairs链接:https://ac.nowcoder.com/acm/contest/5667/A来源:牛客网时间限制:C/C++ 3秒,其他语言6秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述Given {n}n strings s_1, s_2, \cdots, s_ns1​ ,s2​ ,⋯,sn​ . Now define {f(s, t)}f(s,t) as the maximum

2020-07-15 17:09:53 760

原创 2020牛客暑期多校训练营(第二场)——H

Happy Triangle链接:https://ac.nowcoder.com/acm/contest/5667/H来源:牛客网时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述Given a multiset {MS}MS and {q}q operations. {MS}MS is empty initailly, and operations are in three types, wh

2020-07-14 22:55:03 246

原创 牛客算法周周练15——D

树上求和链接:https://ac.nowcoder.com/acm/contest/6290/D来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述给你一棵根为1的有N个节点的树,以及Q次操作。每次操作诸如:1 x y:将节点x所在的子树的所有节点的权值加上y2 x:询问x所在子树的所有节点的权值的平方和,答案模23333后输出输入描述:第一行两个整数N,Q第二行N个整数

2020-07-14 21:49:43 214

原创 2020牛客暑期多校训练营(第二场)——B

题意:给定n个点,让更多的点落在同一个经过原点(0,0)的圆上,求出最多的点数。题解:固定一个点,再遍历一遍其他点,加上原点,每次三个点,可以确定一个圆,手动推出圆心坐标的公式,然后遍历出有多少个点落在这个圆上,求出最大值即可。推圆心坐标:两点确定一条直线,三点求出两条直线,再求出这两条直线的垂线,再求出两条直线的交点即可。#include<bits/stdc++.h>using namespace std;typedef long long ll;typedef pair&lt.

2020-07-13 22:58:58 311

原创 Atcoder-AIsing Programming Contest 2020-D

Anything Goes to Zero题意:给定一个二进制串,按位计算,计算每一位时,取反,得到一个二进制数,用其取余其二进制下1的个数,得到结果,再执行同样的取余步骤,直到结果为0,输出所需的步数。做法:每一位取反,在二进制下1的个数,就是整体串中1的个数加一或减一,先预处理出不取反时的结果,然后每一位判断,加上或减去该位的变化,计算结果即可。简单来说就是:先这样,再这样,然后这样,最后输出就好了。切记快速幂时,数据类型定义为longlong,不然就会乘炸了(因题而定)。比赛时没开long

2020-07-12 22:26:44 187

原创 2019南昌邀请赛-F

F - SequenceOldjang has a sequence A of length n , the i t h number in which is A i . He defined a function f ( l , r ) = a l ⊕ a l + 1 ⊕ ⋯ ⊕ a r . It is simple for the cleverest boy oldjang to calculate the function, so he wants to make the problem more

2020-07-08 18:01:36 160

原创 2019-icpc西安邀请赛-C

Angel’s Journey“Miyane!” This day Hana asks Miyako for help again. Hana plays the part of angel on the stage show of the cultural festival, and she is going to look for her human friend, Hinata. So she must find the shortest path to Hinata’s house. The ar

2020-07-06 23:23:51 416

原创 第三届中国计量大学ACM程序设计竞赛个人赛(同步赛)——L

链接:https://ac.nowcoder.com/acm/contest/5795/L来源:牛客网题目描述One day, Little Gyro was playing with a series of Bracket Sequences, A Bracket Sequence is a string that only contains two kinds of characters ‘(’ and ‘)’. Let us define a regular Bracket Sequence i

2020-06-03 22:41:34 456

原创 牛客联系赛62-B

在 t 秒内,走 x 次向上的,走 y 次向右的,所以答案是组合数学。#include<stdio.h>#include<algorithm>using namespace std;typedef long long ll;const ll mod=998244353;const int N=1e5;ll jc[N],inv[N];ll quick_mod...

2020-04-29 16:50:01 189

原创 牛客练习赛60-D

比赛的时候没有做出来,今天补题的时候看了大佬的代码,也不至于太难理解,但当时就是没想出来,只能说大佬牛逼。K取余C,余下的部分用A和B补。先预处理出X个A取余C的所以情况,每种情况各需要几个A,B同样预处理出来,然后让X个A和Y个B取余C的余数凑出K取余C的余数即可。#include<bits/stdc++.h>using namespace std;typedef long ...

2020-03-28 11:55:51 176

原创 Codeforces-1323D

D. PresentCatherine received an array of integers as a gift for March 8. Eventually she grew bored with it, and she started calculated various useless characteristics for it. She succeeded to do it f...

2020-03-09 19:38:35 269

原创 ST表

ST表入门ST表类似树状数组,线段树这两种算法,是一种用于解决RMQ(Range Minimum/Maximum Query,即区间最值查询)问题的离线算法与线段树相比,预处理复杂度同为O(nlogn),查询时间上,ST表为O(1),线段树为O(nlogn)贴一道模板题洛谷:https://www.luogu.com.cn/problem/P3865板子:#include<bi...

2020-03-03 19:24:38 119

原创 HDU 5984

Pocky HDU - 5984Let’s talking about something of eating a pocky. Here is a Decorer Pocky, with colorful decorative stripes in the coating, of length L.While the length of remaining pocky is longer t...

2020-02-05 14:24:28 164

原创 2020 CCPC-Wannafly Winter Camp

Day1 (Div.1&2)——A7-1 1A. 期望逆序对题解:主要考虑以上两种情况贪心排序时按照 a.l+a.r<b.l+b.r 来排序,由于逆序对要求最小,所以当满足图上标号为b的长度小于a的长度时可以满足逆序对最小,可以推出上式子。计算期望时,依据上图可推出式子,注意公共部分取二分之一。#include<bits/stdc++.h>using...

2020-02-04 23:09:06 227

原创 CodeForces - 1284C

New Year and PermutationRecall 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 [1,2,2] is not a permu...

2020-01-05 11:21:42 240

原创 AcWing-244.谜一样的牛

题解:从后往前依次判断牛的高度,当前牛之前有a个牛比它低,则当前牛的最低身高为a+1,所以当前牛的高度为所有牛的第a+1低,然后二分判断当前所有牛中第a+1,低的牛身高为多少,当前每头牛被选走之后,记录一下。用树状数组维护牛身高的序列,前缀和求第几高,当牛被选走之后,该身高位置减一即可。#include<stdio.h>#include<algorithm>us...

2020-01-04 19:59:59 253

空空如也

空空如也

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

TA关注的人

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