- 博客(59)
- 资源 (1)
- 收藏
- 关注
转载 运算符优先级表
运算符优先级表题目:如果X大于0并小于65536,用移位法计算X乘以255的值?答案是:(X)-X做题时发现对于运算符优先级还是没有概念,于是找来优先级表和口诀帮助记忆。优先级运算符名称或含义使用形式结合方向说明1[]数组下标数组名[常量表达式]
2015-08-27 23:02:42
1013
原创 poj 3695 矩阵切割
题意:给N个矩形,他们可能会重叠,然后给M个询问,每个询问给出指定的矩形位置,然后分别计算每个询问中选中的矩形的并。矩阵切割就可以了。#include typedef long long ll;int n,m;int X1[40],Y1[40],X2[40],Y2[40];int sum[40];int a[40];int r;void cover(int x1, i
2015-10-26 18:16:03
655
原创 hdu 3943 数位dp+二分
题意: 求p - q 范围内满足有x个4和y个7的第K个数。思路: 数位dp。然后二分位置。code#include <bits/stdc++.h>using namespace std;typedef long long ll;int T;ll p, q;int query;int x, y;int num[10010];ll dp[100][100][100];ll dfs(i
2015-10-24 20:38:50
475
原创 hdu 3944 lucas
需要分情况讨论。 然后求组合数 套上lucas。#include using namespace std;typedef long long ll;ll n, k, p;ll powmod(ll a, ll b){ ll res = 1; a %= p; while(b){ if(b&1) res = res*a%p; b>>=1; a = a*a%p; } return
2015-10-24 13:03:20
476
原创 cdoj 1131 区间dp
男神的礼物Time Limit: 3000/3000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)Submit StatusLweb学长是集训队里公认的男神。有一天他要给美美的学姐姐准备礼物。Lweb学长可是会魔法的哟。为了准备一份礼物,男神要加工n份材料。每一次只能加工相
2015-10-22 14:39:58
632
原创 hdu 4059 小学生容斥
啥都不说。。送上一个四次方求和公式:Sum(n)=n*(n+1)*(2n+1)(3n^2+3n-1)/30 再送上一个三次方求和公式: Sum(n) = (1+2+3+…+n)^2 抄的code#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>#define LL long long#define
2015-10-22 11:05:15
657
原创 poj 3904 容斥原理
题目: 求一个数组里面,gcd(a, b, c, d) = 1的四元组的组数。容斥。 如果直接正向容斥,状态太多。 所以我们考虑对每一个数进行分解。 记录一下这个数可以被哪些数整除。这里利用的是唯一分解定理:任意一个数都只能被拆成一种质因子相乘的形式。code:#include #include #include #include #include using na
2015-10-21 16:06:11
635
原创 hdu 3208 简单容斥原理
好题。学会了一种处理溢出的技巧。。from acdreamer's blogcode: #include #include #include #include #include #include #include #include #include using namespace std;#define rep(i,a,n) for (
2015-10-12 00:23:48
544
原创 uva 11468 ac自动机+dp
题意: 求最后构成的长度为L的字符串不含有模式串的概率,没一个字符的概率已经给出来了。思路: 自动机构造转移,然后dp[i][j]表示现在是第i步,在j这个状态。 转移方程就很好写了。code:#include <iostream>#include <queue>#include <cstring>#include <cstdio>#include <algorithm>us
2015-10-08 21:23:15
417
原创 uva 1449 AC自动机
题意: 求在匹配串中出现次数最多的模式串。思路: AC自动机裸题。 稍微改一下。。code: #include <iostream>#include <queue>#include <cstring>#include <cstdio>#include <algorithm>#include <map>using namespace std;int hs[1600];int n;
2015-10-08 19:31:06
542
原创 cdoj 86 Divide
题意: 给你n种物品,每种物品的价值是2^a(0<=a<=1e5),每种物品有b(0<=b<=1e9)个,让你把这些物品分成两堆,让两堆之间的差值最小。做法: 首先我们从高位向低位看 1.如果这位上的个数恰好是偶数,那么是不是就可以平均分? 2.然后如果是奇数的话,是不是就要看看它后面的数能不能补足这个差值? 那么这样的话。我们先预处理一下,把所有的位都进位化成2
2015-10-08 14:59:56
610
原创 hdu 3967 数位dp
题意:求a-b区间内的满足可以把一个数左右分开从而使分开的两个数的和被k除尽的数的个数。这么道一般的数位dp。。 居然没做出来... 智商不够用啊。。#include using namespace std;typedef long long ll;int num[30];ll dp[30][30][30][2][30];int k; int pos;lon
2015-10-05 13:36:59
614
原创 hdu 3971
杭电2015级新生如何加入ACM集训队? Play With SequenceTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 452 Accepted Submission(s): 228
2015-10-03 12:22:43
555
原创 cdoj 1144 二分图最大匹配.. 裸题
来一道裸题~http://acm.uestc.edu.cn/#/problem/show/1144#include using namespace std;const int MAXN = 220;int uN,vN;int g[MAXN][MAXN];int linker[MAXN];bool used[MAXN];int match[MAXN];bool dfs(i
2015-10-02 19:53:31
536
原创 scu oj 4443
题目: http://www.bnuoj.com/v3/contest_show.php?cid=6865#problem/H解法: 位置和数字可以转化成二分图模型。必须是完备匹配才有解。主要是这个限制关系比较难找。 然后就是字典序最小的二分图匹配了。#include using namespace std;const int MAXN = 52;int uN,vN;int
2015-10-02 19:29:27
1058
原创 codeforces Zublicanes and Mumocrates
给你一棵树,问你把子节点分成两类的最少去掉的边的数量。 边的两个端点颜色不同必须去掉。树形背包;#include using namespace std;const int INF = 0x3f3f3f3f;const int MAXN = 5011;struct node{ int to,next;}edge[MAXN*2];int tot,head[MAX
2015-09-29 23:57:02
733
原创 hdu 5493
QueueTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 348 Accepted Submission(s): 194Problem DescriptionN people numbered fr
2015-09-29 18:13:51
586
原创 hdu 5489
题意: 求去掉一段连续的长度为L的区间后的最长上升子序列。解法: 首先预处理出f[i], g[i]; f[i] : 以第i个位置为开头的最长上升子序列。g[i]: 以第i个位置为结尾的最长上升子序列。预处理的复杂度是nlogn的 这里的预处理方法是基于贪心的思想。然后一位一位的扫, 当扫到第i位,它的答案标号在(1, i-k-1) 这个区间假设为x, 那么a[x]
2015-09-29 11:27:27
653
原创 codeforces round 321 div2 题解
A:最长上升子串 #include #include #include #include #include #include #include #include using namespace std;#define rep(i,a,n) for (int i=a;i<=n;i++)#define per(i,n,a) for (int i=n;i>=a;i--)#def
2015-09-28 20:23:23
553
原创 cdoj 84 Binary Operations
Binary OperationsTime Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)Submit StatusBob has a sequence of N integers. They are so attractive, that
2015-09-25 15:46:33
692
原创 cdoj 92 Journey lca
题意:给定一棵树, 然后加一条边, 有若干询问, 问你每一个询问(u,v), 加了这条边后可以从u到v节省多少距离。思路: 一共三种情况, 1, 原路 2,u - x - y - v 3,u - y - x - v#include using namespace std;const int MAXN = 100010;struct node{ int to,
2015-09-25 12:37:35
458
原创 51nod 1232 完美数 / codeforces 55D 数位DP
1232 完美数题目来源: 胡仁东基准时间限制:2 秒 空间限制:131072 KB 分值: 160 难度:6级算法题如果一个数能够被组成它的各个非0数字整除,则称它是完美数。例如:1-9都是完美数,10,11,12,101都是完美数,但是13就不是完美数(因为13不能被数字3整除)。现在给定正整数x,y,求x和y之间(包含x和y的闭区间)共有多少完美数。
2015-09-18 21:26:46
1656
原创 hdu 5381 莫队...
The sum of gcdTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 854 Accepted Submission(s): 363Problem DescriptionYou have an a
2015-09-18 19:42:23
518
原创 BZOJ 2152: 聪聪可可 点分治/树dp
2152: 聪聪可可Time Limit: 3 Sec Memory Limit: 259 MBSubmit: 1085 Solved: 562[Submit][Status][Discuss]Description聪聪和可可是兄弟俩,他们俩经常为了一些琐事打起来,例如家中只剩下最后一根冰棍而两人都想吃、两个人都想玩儿电脑(可是他们家只有一台电脑)……遇到这种问题,一般
2015-09-17 21:52:04
541
原创 51Nod 1459 迷宫游戏 dijkstra拓展
1459 迷宫游戏基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题你来到一个迷宫前。该迷宫由若干个房间组成,每个房间都有一个得分,第一次进入这个房间,你就可以得到这个分数。还有若干双向道路连结这些房间,你沿着这些道路从一个房间走到另外一个房间需要一些时间。游戏规定了你的起点和终点房间,你首要目标是从起点尽快到达终点,在满足首要目标的前提下,使得你
2015-09-17 21:48:45
1866
原创 codefroces round 320 div2 题解
A: 水题#include using namespace std;#define rep(i,a,n) for (int i=a;i<=n;i++)#define per(i,n,a) for (int i=n;i>=a;i--)#define pb push_back#define mp make_pair#define all(x) (x).begin(),(x).end()
2015-09-17 18:14:02
483
原创 hdu 4427 三维dp
题意: 问k个数可以形成sum=n, LCM = m的数量 (n,m思路: dp[i+1][j+v][lcm(k, v)] += dp[i][j][k].... 然后。。。需要各种优化。。。。 坑。。。#include using namespace std;int n,m,k;const int mod = 1e9+7;int dp[2][1011][1011];vec
2015-09-16 19:28:29
748
原创 poj 2114 点分治
又做了一道点分治入门题.... 比较卡人的地方是。。 给你一个排好序的序列, 让你求出里面任意两个数字加起来等于k的二元组的个数。。 O(n)扫一遍。。#include #include #include #include #include using namespace std;int n,k;const int maxn = 10010;const int INF = 0x
2015-09-16 16:42:17
645
原创 poj 1741 点分治论文题
题意: 给你一棵树, 让你求这棵树上满足dis(u, v) <= k的点对有多少个。 分析: 首先, 对于直接想到的办法。lca预处理然后暴力,复杂度n^2,显然复杂度太大。 那么我们就有了树上分治的思想; 首先, 对于这个问题, 我们可以看出只有如下三种情况: 然后分治处理。 这里要注意,分治的时候要求重心, 因为重心可以保证
2015-09-15 20:25:43
503
原创 codeforces round 319 div2 题解
A:水题。#include using namespace std;#define rep(i,a,n) for (int i=a;i<=n;i++)#define per(i,n,a) for (int i=n;i>=a;i--)#define pb push_back#define mp make_pair#define all(x) (x).begin(),(x).end(
2015-09-15 17:34:05
467
原创 ural 1013
1013. K-based Numbers. Version 3Time limit: 0.5 secondMemory limit: 64 MBLet’s consider K-based numbers, containing exactly N digits. We define a number to be valid if its K-based notati
2015-09-14 20:23:19
826
原创 ural 1012
1012. K-based Numbers. Version 2Time limit: 0.5 secondMemory limit: 16 MBLet’s consider K-based numbers, containing exactly N digits. We define a number to be valid if its K-based notati
2015-09-14 11:44:21
526
原创 ural 1009
1009. K-based NumbersTime limit: 1.0 secondMemory limit: 64 MBLet’s consider K-based numbers, containing exactly N digits. We define a number to be valid if its K-based notation doesn’t
2015-09-14 10:58:20
521
原创 poj 3468 splay入门
存个模板。从其它地方改过来的。。 区间修改,区间查询#include <iostream>#include <fstream>#include <string>#include <time.h>#include <vector>#include <map>#include <queue>#include <algorithm>#include <cstring>#include
2015-09-11 21:27:50
461
原创 hdu 4010 LCT
题意很裸,调了好久,,最后发现push_up写错了,, splay功底还是不够, 再刷一波splay...#include using namespace std;int n,m;const int MAXN = 310010;const int INF = 0x3f3f3f3f;struct Node *null;struct Node{ Node * fa, *ch[2
2015-09-11 14:23:03
430
原创 hdu 4348 主席树
主席树 区间更新。 好题目; 又学会了一种方法。。 这种方法可以不写push_down;还有就是。。 这里一定要提前建树, 不然空间复杂度为 (n+q)*logn 如果建树为n+ q*logn;#include using namespace std;int n,m;const int MAXN = 4000010;typedef long long ll;ll sum[
2015-09-10 11:38:39
505
原创 理解中国剩余定理
首先, 我们要知道中国剩余定理是用来解决 解一组模数互质的模线性方程 的东西。比如 x1 = a1( mod b1);x2 = a2( mod b2);x3 = a3( mod b3);x4 = a4( mod b4);......这里的 b1,b2,b3,b4.....bn 互质.我们设要求的答案为S; 设a = a1*a2*a3*....*an; 设m =
2015-09-09 20:35:42
646
原创 codeforces round 315 div2 题解
数学专场..A : 推公式#include using namespace std;int t,s,q;int main(){ cin>>t>>s>>q; int res = 0; while(s<t){ int x = s*q; s = x; res++; } cout<<res<<endl; return 0;}B: 考虑中间那个位置乱搞一下
2015-09-06 16:47:36
446
原创 poj 1256 Pick定理
题目意思: 求在这个多边形内部的格点,边上的格点, 还有多边形面积。这里有这样几条定理:解题思路:这个题用了很多知识点:1、以格子点为顶点的线段,覆盖的点的个数为GCD(dx,dy),其中,dxdy分别为线段横向占的点数和纵向占的点数。如果dx或dy为0,则覆盖的点数为dy或dx。2、Pick公式:平面上以格子点为顶点的简单多边形的面积=边上的点数/2+内部的点数+
2015-09-02 20:27:57
556
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅