自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 字节跳动0825笔试场第二题合法表达式(动态规划)

 很明显是一道动态规划的题,刚开始天真想用一维dp[n]来解决,结果发现想的太简单,比如(40)4就是不合法的,所以要用二维动态规划分情况来考虑,dp[i][0]表示长度为i且最后一位为数字(0-9)的个数,dp[i][1]表示长度为i且最后一位为右括号的个数。状态转移方程为:dp[i][0]=(dp[i-1][0]*10+(dp[i-2][0]+dp[i-2][1])*10*2LL)//...

2018-08-26 21:32:00 891

原创 hdu 1576 ex_gcd

A/BTime Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2805    Accepted Submission(s): 2073Problem Description要求(A/B)%9973,但由于A很大,我们只给出n

2015-06-22 15:41:30 717

原创 POJ 1061 扩展gcd 线性同余方程

青蛙的约会Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 95733 Accepted: 17846Description两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止

2015-06-22 14:09:58 647

原创 2015东北四省赛 L题 线性筛+积性函数 求因子和

Given an interval [x, y], calculate the sum of all the factors of the whole integers from x to y (include x and y).Let describe it officially. Let's definite f (i) is the sum of factors of i, you sh

2015-06-17 20:46:19 1409

原创 hdu 5269 01字典树

ZYB loves Xor ITime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 306    Accepted Submission(s): 151Problem DescriptionMemphis loves xo

2015-06-14 19:00:14 521

原创 poj 3764 字典树求异或最大值

The xor-longest PathTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 4290 Accepted: 952DescriptionIn an edge-weighted tree, the xor-length of a path p

2015-06-14 16:56:43 693

原创 poj 2001 字典树入门题(数组实现模板)

#include #include#include#includeusing namespace std;int ch[20*1000+200][27];int sz;int val[20*1000+200];char s[1010][40];void init(){    sz=1;    memset(ch,0,sizeof(ch));

2015-06-14 14:52:23 366

原创 2015 辽宁省赛G题 边权排序

1576: Good Sequence时间限制: 1 Sec  内存限制: 128 MB提交: 12  解决: 5[提交][状态][讨论版]题目描述This is the definition of the good sequence:Suppose sequence the length which is n is : A1,A2...An. If meet the 

2015-06-11 23:53:54 654

原创 2015 辽宁省赛C题 dp+单调队列优化

#include #include#include#include#define ll long longusing namespace std;int n,k;const int maxn=1e5+10;ll sum[maxn];int a[maxn];ll dp[maxn];ll s[maxn];int q[maxn];ll ans[maxn];//void de_

2015-06-11 17:18:58 548

原创 bzoj 2243 树链剖分 染色

2243: [SDOI2011]染色Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 3205  Solved: 1238[Submit][Status][Discuss]Description给定一棵有n个节点的无根树和m个操作,操作有2类:1、将节点a到节点b路径上所有点都染成颜色c;2、询问节点a到节点b路径上的颜

2015-06-03 23:38:51 318

转载 cf 546 E dinic网络流优化模板

/*Author :HRW思路:建图,最大流,注意反向边,容量,流量为0 建源点,汇点, 最后输出路径保证每条边的流量都要输出,只需之前统计有哪些边流量发生了变化*/#include using namespace std;const int N=305;const int inf=0x3f3f3f3f;struct Edge{ int from,

2015-06-03 18:36:09 404

原创 cf 547B 单调栈

#include #include#include#includeusing namespace std;const int maxn=2e5+10;int lst[maxn],nxt[maxn];int a[maxn],s[maxn];int n;int tp;int ans[maxn];void getPos(int i){    lst[i

2015-06-03 16:10:09 603

原创 cf 547C 容斥原理

#include #include#include#include#define ll long longusing namespace std;const int N =500000+10;vector fac[N];int vis[N],cnt[N],v[N];int n,q,a[N];ll ans;int x;void dfs(int u,in

2015-06-03 00:36:21 802

原创 spoj375 重学树链剖分

题意:给定一棵树,告诉了每条边的权值,然后给出两种操作:(1)把第i条边的权值改为val#include #include#include#includeusing namespace std;//siz[v]表示以v为根的子树的节点数//dep[v]表示v的深度(根深度为1)//top[v]表示v所在的链的顶端节点//fa[v]表示v的父亲//son[v]表示与v在同一重链

2015-06-02 01:01:46 429 1

原创 poj 1741 树的点分治

TreeTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 12913 Accepted: 4128DescriptionGive a tree with n vertices,each edge has a length(positive integer les

2015-06-01 20:22:13 344

转载 hdu 1890 splay 区间翻转

#include#include#includeusing namespace std;const int maxn=100000+100;int n;struct SplayTree{    int pre[maxn],ch[maxn][2],size[maxn],rev[maxn],root;    void Update_Rev(int r)    {

2015-05-29 10:18:13 529

原创 hdu 3487 区间翻转

#include #include#include#include#define key_value ch[ch[root][1]][0]#define ls(r) ch[r][0]#define rs(r) ch[r][1]#define ll long longconst int N=300015;using namespace std;int n,q;int sz[N]

2015-05-28 19:10:09 485

原创 bzoj 1208 splay基本操作(插入,查询,删除)

1208: [HNOI2004]宠物收养所Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 5062  Solved: 1945[Submit][Status][Discuss]Description最近,阿Q开了一间宠物收养所。收养所提供两种服务:收养被主人遗弃的宠物和让新的主人领养这些宠物。每个领养者都希望领养到自己满意

2015-05-21 16:26:27 1317

原创 bzoj 1588 splay入门题 (插入,查询)

1588: [HNOI2002]营业额统计Time Limit: 5 Sec  Memory Limit: 162 MBSubmit: 10070  Solved: 3462[Submit][Status][Discuss]Description营业额统计 Tiger最近被公司升任为营业部经理,他上任后接受公司交给的第一项任务便是统计并分析公司成立以来的营业情况。 Ti

2015-05-21 14:01:51 561

原创 poj 2104 区间第K小 主席树入门题

K-th NumberTime Limit: 20000MS Memory Limit: 65536KTotal Submissions: 40933 Accepted: 13377Case Time Limit: 2000MSDescriptionYou are working for Macrohard com

2015-05-21 10:31:13 369

原创 hdu 5230 整数划分+dp+滚动数组

ZCC loves hackingTime Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/131072 K (Java/Others)Total Submission(s): 223    Accepted Submission(s): 92Problem DescriptionNow, a Codefi

2015-05-20 01:43:09 452

原创 hdu 5229 必胜策略

题意ZCC有N个字符串,他正在和Miss G.用这N个字符串玩一个小游戏。ZCC会从这N个串中等概率随机选两个字符串(不可以是同一个)。然后,ZCC和Miss G.轮流操作。Miss G.总是先操作的。在每轮中,操作者可以选择操作A或操作B。操作A:在两个串中选择一个当前非空的串,然后在这个串的末尾删去一个字符。 操作B: 若当前两个串完全相同且非空,则可以使用这个操作。此时两个串

2015-05-19 21:33:57 429

原创 hdu 5228 暴力枚举

#include #include#include#includeusing namespace std;int has[13*4];char s[5];int main(){ int t; cin>>t; while(t--) { memset(has,0,sizeof(has)); for(int i=

2015-05-19 00:21:49 805

原创 hdu 2993 斜率优化+二分查找

#include#include#include#include#include#define ll long longusing namespace std;const int MAXN=100010;ll sum[MAXN];int q[MAXN];int top;long long cross(int a,int b,int c){

2015-05-14 16:31:19 352

原创 后缀数组模板代码

#include#include#includeusing namespace std;//sa[i] : 表示 排在第i位的后缀 起始下标//rank[i] : 表示后缀 suffix(i)排在第几//height[i] : 表示 sa[i-1] 与 sa[i] 的LCP 值//h[i]: 表示 suffix(i)与其排名前一位的 LCP值const int N = int(2e

2015-05-13 16:47:20 317

原创 poj 1743 后缀数组+二分判定

#include#include#include#includeusing namespace std;//sa[i] : 表示 排在第i位的后缀 起始下标//rank[i] : 表示后缀 suffix(i)排在第几//height[i] : 表示 sa[i-1] 与 sa[i] 的LCP 值//h[i]: 表示 suffix(i)与其排名前一位的 LCP值const int N

2015-05-13 16:46:11 290

原创 hdu 5223 GCD 思维题

GCDTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 506    Accepted Submission(s): 227Problem DescriptionIn mathematics, the greate

2015-05-12 20:04:44 446

原创 hihocoder 1166 期望dp+高斯消元

#1166 : 交换代数时间限制:20000ms单点时限:1000ms内存限制:256MB描述少女幽香这几天正在学习交换代数,然而她什么也没有学会,非常痛苦。于是她开始玩起了一个简单的小游戏,来放松一下。地面上一共有n个球,一开始有一些是黑色的,有一些是白色的。每次她随机选择一个区间(一共有n(n+1)/2个区间,每个区间有相等的概率被选

2015-05-11 23:40:41 627

原创 hiho 11 B-益智游戏(随机数+暴力求解+分解质因子)

益智游戏时间限制:20000ms单点时限:1000ms内存限制:256MB描述幽香今天心情不错,正在和花田里的虫子玩一个益智游戏。这个游戏是这样的,对于一个数组A,幽香从A中选择一个数a,虫子从A中选择一个数b。a和b可以相同。她们的分数是a*b的因子的个数。幽香和虫子当然想要获得尽可能的高的分数,你能告诉她们应该选择哪两个数吗。由于

2015-05-05 23:28:23 404

原创 RMQ模板(一般结合后缀数组使用)

#include #include#include#include#includeusing namespace std;int a[100];int dp[100][15];//2^15足够大int rmq(int s,int v){ int k=(int)(log(2.0*(v-s+1)*1.0)); return min(dp[s][k],dp[v-(1<<

2015-05-03 17:22:56 309

原创 CF 459E && 市赛I题

E. Pashmak and Graphtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPashmak's homework is a problem about graphs. Alt

2015-05-03 11:05:35 494

原创 hdu 3507 斜率dp优化

#include #include#include#includeusing namespace std;const int maxn=500000+10;int dp[maxn],q[maxn],sum[maxn];int n,m;int getdp(int i,int j){ return dp[j]+m+(sum[i]-sum[j])*(sum[i]-sum[j])

2015-05-02 23:14:33 268

原创 人生不如意十之八九,但是那一二就是我们继续坚持下去的动力。

唯有四月的挫折与困难,才能激励我们坚持5月、6月甚至10月的长征!

2015-05-02 21:31:14 874 1

原创 hdu 2829 重学四边形不等式优化

#include #include#include#include#define ll long longusing namespace std;const int maxn=1010;const int inf=1e9+7;ll cost[maxn][maxn],dp[maxn][maxn],s[maxn][maxn];void DP(int n,int m){ fo

2015-05-02 20:56:20 276

原创 2015编程之美资格赛2题—区间dp

题目2 : 回文字符序列时间限制:2000ms单点时限:1000ms内存限制:256MB描述给定字符串,求它的回文子序列个数。回文子序列反转字符顺序后仍然与原序列相同。例如字符串aba中,回文子序列为"a", "a", "aa", "b", "aba",共5个。内容相同位置不同的子序列算不同的子序列。输入第一行一个整数T,表示数据

2015-04-19 01:23:21 429 1

原创 hdu 5201 容斥原理+组合数取模

The Monkey KingTime Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 207    Accepted Submission(s): 64Problem DescriptionAs everyone known

2015-04-09 20:56:13 440

原创 hdu 5200 离线处理+思维

#include #include#include#includeusing namespace std;const int maxn=50000+10;struct node{    int id;    int val;}p[maxn],q[maxn];int vis[maxn],ans[maxn];bool cmp(node a,node b)

2015-04-08 21:39:00 335

原创 hdu 5199 map水题

#include #include#include#include#includeusing namespace std;mapa;int main(){   int n,m;   while(~scanf("%d%d",&n,&m))   {       int x;       for(int i=1;i       {       

2015-04-08 20:59:32 383

原创 POJ 1012 约瑟夫环推公式

#include #include#include#includeusing namespace std;    int n,k;bool ok(int m){    int s=0;    for(int i=1;i    {        s=(s+(m-1))%(n-i+1);        if(s            return 0

2015-04-08 20:09:31 350

空空如也

空空如也

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

TA关注的人

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