自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

FreeGo~

永远相信美好的事情即将发生~

  • 博客(124)
  • 收藏
  • 关注

原创 线段树之点更新区间求和模板题-hdu1166

http://acm.hdu.edu.cn/showproblem.php?pid=1166#include<bits/stdc++.h>using namespace std;const int maxn=200000+10;int a[maxn],t[maxn<<2];int N;char str[233];int L,R;void pushup(int k){ t[k]=t[k<<1]+t[k<<1|1];}void bui

2020-10-25 15:35:59 135

原创 线段树之点更新求最值模板题 hdu1754

#include<iostream>using namespace std;const int maxn=200000+10;const int INF=0x3f3f3f3f;int a[maxn],t[maxn<<2];int N,M;char str;int L,R;void pushup(int k){ t[k]=max(t[k<<1],t[k<<1|1]);}void build(int l,int r,int k){

2020-10-25 15:32:53 156

原创 线段树-区间更新-区间求和模板题 洛谷P3372

线段树-区间更新-区间求和模板题 洛谷P3372#include<bits/stdc++.h>using namespace std;const int maxn=1e5+7;typedef long long ll;ll t[maxn<<2];ll a[maxn];int lazy[maxn<<2];int n,m;void pushup(int k){ t[k]=t[k<<1]+t[k<<1|1];}void

2020-10-25 15:30:27 157

原创 Linux基础命令

2020-01-14 21:21:32 131

原创 C++的String类简单实现

String类实现,构造函数,初始化函数,析构函数,重载=,+=运算符,定义友元函数+,<<运算符,SubStr子串函数。#include<iostream>#include<cstring>using namespace std;class String{ private: char* str; int le...

2019-11-03 14:57:09 198

原创 CH3101 阶乘质因数分解

题意3101 阶乘分解 0x30「数学知识」例题描述给定整数 N(1≤N≤10^6),试把阶乘 N! 分解质因数,按照算术基本定理的形式输出分解结果中的 p_i 和 c_i 即可。输入格式一个整数N。输出格式N! 分解质因数后的结果,共若干行,每行一对pi, ci,表示含有pi^ci项。按照pi从小到大的顺序输出。样例输入5样例输出2 33 15 1样例解释5! = ...

2019-09-06 10:10:05 528

原创 POJ-2689 Prime Distance 区间筛法

区间筛法:L~R,先筛出根号R的素数,再用这些素数把L ~ R的合数筛掉,剩下就是素数,适合R大,区间小的素数区间。题目链接: http://poj.org/problem?id=2689题意: 给出一个区间 [l, r] 求其中相邻的距离最近和最远的素数对 . 其中 1 <= l < r <= 2,147,483,647, r - l <= 1e6 .思路: 素数...

2019-09-05 23:58:09 181

原创 hdu1133 Buy the Ticket(卡特兰数变形n个入栈m个出栈问题)

Buy the TicketTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8673 Accepted Submission(s): 3622Problem DescriptionThe “Harry Potter and t...

2019-05-16 21:51:03 198

原创 XYNUOJ 幂字符串

题目描述给你一个字符串,请你判断将此字符串转化成a^n形式的最大的n是多少。例如:abcd=(abcd)^1,则n=1;aaaa=a^4,则n=4;ababab=(ab)^3,则n=3。输入输入包含多组测试数据。每组输入为一个字符串,长度不超过100,其中不包含空格等空白符。当输入为一个“.”时,输入结束。输出对于每组输入,输出将此字符串转化成a^n形式的最大的n。样例输入ab...

2019-05-14 16:00:16 378

原创 洛谷P1087 FBI树

题目描述我们可以把由“00”和“11”组成的字符串分为三类:全“00”串称为BB串,全“11”串称为I串,既含“00”又含“11”的串则称为F串。FBIFBI树是一种二叉树,它的结点类型也包括FF结点,BB结点和I结点三种。由一个长度为2^N2N的“0101”串S可以构造出一棵FBIFBI树TT,递归的构造方法如下:TT的根结点为RR,其类型与串SS的类型相同;若串SS的长度大...

2019-05-14 16:00:10 114

原创 卡特兰数专题训练

1.进栈出栈序列组合数问题HDU - 1023 Train Problem IIAs we all know the Train Problem I, the boss of the Ignatius Train Station want to know if all the trains come in strict-increasing order, how many orders th...

2019-05-13 23:00:12 281

转载 ACM中的数学问题合集

https://blog.csdn.net/jk_chen_acmer/article/details/81976384

2019-05-13 22:25:27 402

原创 质因数分解模板

void find_fat(int val){ tot=0; for(int i=2;i*i<=val;i++) { if(val%i==0) { fat[++tot]=i; } while(val%i==0) val/=i; } if(va...

2019-05-13 21:58:14 1068

原创 扩展欧几里得求逆元模板

int exgcd(int a,int b,int &x,int &y){ int d=a; if(b!=0) { d=exgcd(b,a%b,y,x); y-=a/b*x; } else { x=1; y=0; } return d;}int in...

2019-05-13 21:57:49 1027

原创 HDU 3240 Counting Binary Trees(卡特兰数前n项和取模,i+1和模m不一定互质情况)

There are 5 distinct binary trees of 3 nodes:Let T(n) be the number of distinct non-empty binary trees of no more than n nodes, your task is to calculate T(n) mod m.InputThe input contains at most...

2019-05-13 21:52:48 255 1

转载 2017年“华信智原杯”安徽省大学生程序设计大赛C题-刷票

C. 刷票题目描述:有一个选秀比赛,节目组按照观众的投票情况决定选手的去留。为了给旗下 艺人造势,A 公司收买了一批水军来刷票。已知现在有 n 名选手同台竞争,依次 编号 1…n,A 公司的艺人编号为 1。根据节目组的规定,每人只能投票一次,投 票需要在 n 个选手中选出 m 个,这 m 个人每人可以获得一票。A 公司通过秘密 渠道得知了在 A 公司的水军不参与的情况下最终的投票结果,那么 A...

2019-05-13 00:06:49 202

原创 欧拉函数笔记

2.欧拉函数O(n)打表模板:const int maxn=1e6+10;bool check[maxn+10];int phi[maxn+10],prime[maxn+10],tot;void init(){ memset(check,0,sizeof check); phi[1]=1;tot=0; for(int i=2;i<=maxn;i++){ ...

2019-05-12 23:11:09 149

原创 2017年安徽省ACM竞赛J题《看似简单的题目》C++题解----奇数项欧拉函数(带模)的和

参考:https://blog.csdn.net/jal517486222/article/details/89741959#include<bits/stdc++.h>using namespace std;const int maxn=1e6+10;long long g[maxn],f[maxn];bool check[maxn+10];int phi[maxn+10...

2019-05-12 23:10:15 170

转载 卡特兰数模板

原文:https://www.cnblogs.com/LiHior/p/9468916.html1、前三十项卡特兰数表[1,1,2,5,14,42,132,429,1430,4862,16796,58786, 208012,742900,2674440,9694845,35357670,129644790, 477638700,1767263190,6564120420,244662670...

2019-05-08 11:40:46 914

转载 卡特兰数(catalan数)总结 (卡特兰大数、卡特兰大数取模、卡特兰数应用)

原文:https://blog.csdn.net/zuzhiang/article/details/77966726本文讲解卡特兰数的各种递推公式,以及卡特兰数、卡特兰大数、卡特兰大数取模的代码实现,最后再顺带提一下卡特兰数的几个应用。什么是卡特兰数呢?卡特兰数无非是一组有着某种规律的序列。重要的是它的应用。卡特兰数前几项为 : 1, 1, 2, 5, 14, 42, 132, 429, 14...

2019-05-08 11:30:11 379

原创 ZOJ4101Element Swapping (数学+思维)

Element SwappingTime Limit: 1 Second Memory Limit: 65536 KBDreamGrid has an integer sequence and he likes it very much. Unfortunately, his naughty roommate BaoBao swapped two elements and ()...

2019-05-07 23:41:24 148

转载 马拉车算法——求回文子串个数zoj4110

Strings in the PocketTime Limit: 1 Second Memory Limit: 65536 KBBaoBao has just found two strings and in his left pocket, where indicates the -th character in string , and indicates the -th...

2019-05-07 14:43:14 458

原创 淮师大OJ 质因数分解

质因数分解描述已知正整数n是两个不同的质数的乘积,试求出较大的那个质数。输入每组输入数据只有一行,包含一个正整数n。数据规模:对于60%的数据,6≤n≤1000。对于100%的数据,6≤n≤2*10^9。输出每组输出只有一行,包含一个正整数p,即较大的那个质数。输入样例 121输出样例 17来源NOIP全国联赛普及组-2012年NOIP全国联赛普及组题解:枚举出第...

2019-05-06 12:43:20 675

原创 划分数DP n的m划分 poj1664

放苹果Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 39514 Accepted: 24166Description把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1 是同一种分法。Input第一行是测试数据的数目t(0 <= t <...

2019-05-06 12:35:37 155

原创 01背包和完全背包模板

个数从0开始计数容量枚举到Wdp[W] 以容量枚举价值01背包 for(int i=0;i<n;i++) { for(int j=W;j>=w[i];j--)//倒着来 { dp[j]=max(dp[j],dp[j-w[i]]+v[i]); } } cout << dp[...

2019-05-06 11:46:53 254

原创 洛谷P1029 最大公约数和最小公倍数问题

题目描述输入22个正整数x_0,y_0(2 \le x_0<100000,2 \le y_0<=1000000)x0​ ,y0​ (2≤x0​ <100000,2≤y0​ <=1000000),求出满足下列条件的P,QP,Q的个数条件:P,QP,Q是正整数要求P,QP,Q以x_0x0​ 为最大公约数,以y_0y0​ 为最小公倍数....

2019-05-05 15:02:52 553

原创 HPUOJ Triangles

问题 A: Triangles时间限制: 1 Sec 内存限制: 128 MB题目描述已知一个圆的圆周被N个点分成了N段等长圆弧,求任意取三个点,组成锐角三角形的个数。输入多组数据,每组数据一个N(N <= 1000000)输出对于每组数据,输出不同锐角三角形的个数。样例输入345样例输出105解法一:计算锐角三角形的个数,可以用总的三角形的个数减去直角三角形...

2019-05-05 07:33:29 108

原创 ZOJ4109-Welcome Party

Welcome PartyTime Limit: 2 Seconds Memory Limit: 131072 KBThe 44th World Finals of the International Collegiate Programming Contest (ICPC 2020) will be held in Moscow, Russia. To celebrate this...

2019-05-04 11:27:52 159

原创 ZOJ4107-Singing Everywhere

Sequence in the PocketTime Limit: 2 Seconds Memory Limit: 65536 KBDreamGrid has just found an integer sequence in his right pocket. As DreamGrid is bored, he decides to play with the sequence....

2019-05-04 07:57:35 149

原创 hdu-5500 Reorder the Books

Reorder the BooksTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1834 Accepted Submission(s): 949Problem Descriptiondxy has a collectio...

2019-05-04 07:16:11 90

原创 ZOJ Problem Set - 4104 Sequence in the Pocket(排序思维题)

Sequence in the PocketTime Limit: 2 Seconds Memory Limit: 65536 KBDreamGrid has just found an integer sequence in his right pocket. As DreamGrid is bored, he decides to play with the sequence....

2019-05-04 07:02:32 174

原创 zoj-4108 Fibonacci in the Pocket(斐波那契数列奇偶性规律+Java大数)

Fibonacci in the PocketTime Limit: 1 Second Memory Limit: 65536 KBDreamGrid has just found a Fibonacci sequence and two integers and in his right pocket, where indicates the -th element in ...

2019-04-30 17:09:59 786

原创 Codeforces Round #554 (Div. 2) C. Neko does Maths

C. Neko does Mathstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNeko loves divisors. During the latest number theory lesson, he got an inter...

2019-04-26 20:49:17 248

原创 ACM范围

int: 21e9 或 2^31-1longlong: 91e18 或 2^63-11e6约等于2^201e9约等于2^301e18约等于2^60一秒题:1e8*个位数int最大值:0x3f3f3f3flonglong最大值:(1ll<<62)

2019-04-26 20:34:11 607

转载 ACM做题过程中的一些小技巧。

ACM做题过程中的一些小技巧。1.一般用C语言节约空间,要用C++库函数或STL时才用C++;cout、cin和printf、scanf最好不要混用。2.有时候int型不够用,可以用long long或__int64型(两个下划线__)。值类型表示值介于 -2^63 ( -9,223,372,036,854,775,808) 到2^63-1(+9,223,372,036,854,775,8...

2019-04-25 14:10:36 239

原创 Codeforces Round #554 (Div. 2) 1152B - Neko Performs Cat Furrier Transform

笔记:1.2^i: 100000002^i-1:1111111判断x是否是2^i:1.找到位数范围,1e6为020,1e9为030,因为1e6约等于220,1e9约等于2302.循环判断是否可以为1<<i,O(1)复杂度判断x是否为2i-1,先加一,在判断是否为2i2.判断x的第i位数字,x>>i,从左往右找到x的第一个1,就是找到x的最大位i为1从i的...

2019-04-25 13:20:16 260

原创 CodeForces-1155D Beautiful Array(DP)

dp[i][0]:以a[i]结尾的最大字段和,前面先不考虑是不是以a[i]还是a[i]*x结尾dp[i][1]:以a[i]*x结尾的最大字段和,考虑前面是以a[i]还是以a[i]*x结尾dp[i][2]:以a[i]结尾的最大字段和,考虑前面是以a[i],a[i]*x或者前面的前面的以a[i],a[i]*x结尾#include <bits/stdc++.h>using names...

2019-04-23 14:39:17 331

原创 HDU-3746 Cyclic Nacklace(kmp求最小循环节)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3746比如abcabca从1开始计数,计数到tlen:nxt[i]表示以 i 结尾的最长公共前后缀的长度,不包括自身比如字符串a的nxt[0]为0,aa的nxt[1]为1。nxt[i]同时表示前缀的最后一个位置(从1开始计数)nxt[tlen]表示整个字符串的最长公共前后缀长度len=tle...

2019-04-22 16:45:28 117

原创 HDU - 2087 剪花布条(kmp求不可重叠子串个数)

http://acm.hdu.edu.cn/showproblem.php?pid=2087剪花布条Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 34507 Accepted Submission(s): 21017Prob...

2019-04-22 15:01:46 131

原创 KMP模板(复杂度O(m+n))(新)

#include<bits/stdc++.h>using namespace std;const int maxn = 1000002;int nxt[maxn],slen,tlen;char S[maxn],T[maxn];void getNxt(){ int i,j; i=0,j=-1,nxt[0]=-1; while(i<tlen) ...

2019-04-22 14:10:09 705

空空如也

空空如也

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

TA关注的人

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