自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

wind-wing

挥毫洒平生

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

原创 轮廓线 离散化+大顶堆

题目: 给定n座建筑物 B[1, 2, … , n],每个建筑物 B[i]表示为一个矩形,用三元组B[i]=(a_i,b_i,h_i)表示,其中a_i表示建筑左下顶点,b_i表示建筑的右下顶点,h_i表示建筑的高,请设计一个 O(nlogn)的算法求出这n座建筑物的天际轮廓。例如,左下图所示中8座建筑的表示分别为(1,5,11), (2,7,6), (3,9,13), (12,16,7),(14,...

2018-10-11 13:37:07 1152

原创 中国剩余定理 不互质

然,对于不互质的情况,同样可以用它来解。将方程组合并。推导如下 取两方程组 {x = n1*k1 + a1 ; {x = n2*k2 + a2 ; 目标合成为x = n*k + a; 有n1*k1+a1 = n2*k2 + a2 ; 设d = gcd(n1,n2) ; 则有(n1*k1)/d - (n2*k2)/d = (a2-a1)/d; I a:当且仅当 d|(a2-a1) ,

2016-07-15 17:59:40 1214

原创 UVa10003 cutting sticks

区间dp,基本裸题 dp[i][j] = dp[i][k] + dp[k][j] + val(j-i) ; 枚举给定的点即可#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#define min(a,b) (a<b?a:b)#define FOR(a,i,b) for( i = a ; i

2016-07-15 17:57:06 343

原创 中国剩余定理CRT (互质)

中国剩余定理给出了以下的一元线性同余方程组: 有解的判定条件,并用构造法给出了在有解情况下解的具体形式。 中国剩余定理说明:假设整数m1,m2, … ,mn两两互质,则对任意的整数:a1,a2, … ,an,方程组 有解,并且通解可以用如下方式构造得到: 设M是整数m1,m2, … ,mn的乘积,并设Mi是除了mi以外的n- 1个整数的乘积。 设为Mi^-1模mi的数论倒数 : 方

2016-07-15 17:40:52 1282

原创 lucas定理

Lucas 适合大组合数取模。 Lucas定理是用来求 c(n,m) mod p,p为素数的值。 时间复杂度O(logp(n)*p): 表达式C(n,m)%p=C(n/p,m/p)*C(n%p,m%p) 重新证明一遍: 令n=sp+q , m=tp+r .(q ,r ≤p) 原式子=C(sp+q,tp+r)%p (1+x)^nΞ(1+x)^(sp+q)Ξ(1+x)^(sp)*(1+x

2016-07-13 11:37:16 520

原创 HDU3939Sticks and Right Triangle勾股数,容斥,欧拉筛,积性函数

若(a, b, c) 三者互质(它们的最大公因数是 1),它们就称为素勾股数。 勾股数的构造: a = m*m-n*n b = 2m*n c = m*m+n*n 若 m 和 n 是互质,而且 m 和 n 其中有一个是偶数,计算出来的 (a, b, c) 就是素勾股数。(若 m 和 n 都是奇数, (a, b, c) 就会全是偶数,不符合互质。) 题意:给定L,求不大于L的勾股数(a,b,

2016-07-12 15:34:07 537

原创 miller-rabin

概率型素性测试。可以说是历史上对费马小定理的”误“翻译起源,后逐渐发展而成。费尔马小定理:如果p是一个素数,且0#include <iostream>#include <cstdio>#include <cstdlib>typedef long long ll ;using namespace std ;ll multi(ll a, ll b , ll mod){ ll ans =

2016-07-11 10:15:23 386

原创 poj 2480 Longge's problem

#include<cstdio>inline void prin(const int &n){ printf("%lld\n",n) ;}typedef long long ll ;ll quick_pow(ll n , ll k){ ll ans = 1; while(k){ if(k&1) ans *= n; n*=

2016-07-11 10:04:06 254

原创 32位汇编作业

32位汇编程序作业集

2016-06-12 19:59:34 325

原创 BUN16 51640 dp

bunoj%Q#include #include #include #include using namespace std;const int maxn = 1000+100 ;long long a[maxn] ;long long dp[1000][1000] ;int main(){ int t , n , m ; scanf("%d",

2016-06-10 23:03:45 296

原创 Fib 性质 Gcd(f[n],f[m]) = f(gcd(n,m))

a) gcd(fn, fn-1) = 1, for all n b) fm+n = fm+1 fn + fm fn-1 c) if m divides n, then fm divides fn and the ever important Euclidean Algorithm which states: if n=qm+r, then gcd(n,m)=gcd(m,r). Fo

2016-06-07 18:54:20 1498

原创 HDU 2582 f(n)

定理:设,那么的值为      (1)为素数,那么答案就是     (2)有多个素因子,那么答案就是     (3)只有一个素因子,那么答案就是该素因子#include #include #include using namespace std;//int judge(int n){// int tmp = sqrt(n+0.5) ;

2016-06-06 23:40:30 343

原创 hdoj 2685

#include #include using namespace std;int quick(int a, int k ,int mod ){ int ans = 1 ; while(k){ if(k&1) { ans = (ans*a)%mod ; } a *= a; a %= mod

2016-06-05 16:39:36 324

原创 POJ 3233 Matrix Power Series

http://poj.org/problem?id=3233分析表达式,等比矩阵求和sum(k) = A + A^2 + A^3+...A^k  . k 太大容易联想到求矩阵高次幂。sum(k-1) + A^k = sum(k) . 有这个特性,构造出矩阵:|A 1|  ans[0][0] 每次相乘得到A^x , ans[0][1]  每次把ans[0][0] 项加之

2016-06-05 12:31:24 248

原创 B. Chilly Willy

http://codeforces.com/problemset/problem/248/Be , 看错题。。 找能被2,3,5,7整除的最小的数,要求长度为n  不会推,找的规律#include #include #include #include using namespace std;const int maxx = 100000+10 ;//string s[maxn]

2016-06-02 13:59:02 288

原创 HDU 1214

思维要灵活。。

2016-06-01 20:37:31 278

原创 HDU2554

(ai-bi)=i+1all(ai+bi) = (1+2n)2n/2all(ai-bi)=(3+n)n/2#include using namespace std;/*(b1+...+bn) = (n(n+3)/2 + 2n(2n+1)/2 )/2== (5n*n+5*n)/4 5n(n+1)/4(a1+...+an) = ( 3n*n-n)/4 n(3n-1)/4*/

2016-06-01 14:14:47 281

原创 poj 2229

POJ 2229#include <iostream>#include <cmath>using namespace std;/*if n is odd , then f(n) = f(n-1) .because n is odd , add the answer must have at least a 1, and f(n-1) above all solutionselse if

2016-05-31 22:18:07 211

转载 Gauss analysis

//最近一直在做一个数论专题,后期有待整理,先将有关资料收藏下,在学习高斯消元的时候看了czyuan大牛的此文获益匪浅,czyuan的此份模板可以解决大多高斯问题,当然并不是万能的,其中建立矩阵是难点,需要自己琢磨,并且对于方程组是否有解、解的个数以及自由元等问题也需要自己做题慢慢思考,自己做了两三道题前前后后在建矩阵以及对一些解的问题在Gauss函数中改了几十次,逐渐摸索,还不算掌握的好,有待再慢

2016-05-30 21:40:57 341

原创 Gauss poj 1222

POJ 1222#include <iostream>#include <cstdio>#include <cmath>#include <cstdlib>using namespace std;//0x11 1x12 1x13 0x14//1x21 0x22 0x23 1x24//0x31 0x32 1x33 0x34//1x41 0x42 0x43 1x44//-> simpl

2016-05-30 21:28:28 327

原创 Gauss poj 1830

POJ1830 开关问题巧用位运算。 对于有效true的影响:0->1 , 1->0 ; 无效false的影响:0->0 , 1->1 ; true ^ 0->1 , true^1->0 ; false^0->0 , false^1->1 ; 已知结果矩阵,和初始矩阵,和关系矩阵。初始矩阵^(关系矩阵*变元) == 结果矩阵 变换-> 变元*(关系矩阵)=初始矩阵^结果矩阵 变元的值

2016-05-30 18:20:02 273

原创 Gauss template

learn from kuangbin#include <iostream>#include <cmath>#include <cstdio>#include <cstdlib>using namespace std;const int maxn = 50;int a[maxn][maxn]; // zeng guangint x[maxn] ; // ans_xint free_x

2016-05-30 14:02:14 336

原创 Generating function

普通篇 HDU1171#include <iostream>#include <cstdio>#include <cstdlib>using namespace std;int t1[8100],t2[8100] ;/*i:第I个表达式j:第j个变量k:乘第i个表达式子(1+x^i + x^2i + ...) */ int main(){ int num[4] ={0}

2016-05-28 18:43:57 281

原创 为了一些不为什么的坚持

连兴趣都不能坚持,还想做什么?  为什么要问那么多为什么?

2016-05-27 22:36:17 379

原创 HDU 5242 Game

Problem DescriptionIt is well known that Keima Katsuragi is The Capturing God because of his exceptional skills and experience in ''capturing'' virtual girls in gal games. He is able to playk ga

2015-09-05 15:57:57 393

原创 HDU 5241 Friends

FriendsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 556 Accepted Submission(s): 283Problem DescriptionMike has many friends.

2015-09-05 10:24:49 887

原创 HDU 5240 Exam

ExamTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 714 Accepted Submission(s): 360HDU 5240Problem DescriptionAs this term is going

2015-09-05 09:03:46 362

原创 HDU 5237 Base64

Base64Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 545 Accepted Submission(s): 220HDU 5237Problem DescriptionMike does not wan

2015-09-05 09:01:40 593

原创 Codeforces Round #317 [AimFund Thanks-Round] (Div. 2) B. Order Book

B. Order Booktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn this task you need to process a set of stock exchange orders a

2015-08-23 08:38:01 807

原创 POJ 2533 Longest Ordered Subsequence

Longest Ordered SubsequenceTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 39246 Accepted: 17258DescriptionA numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subseq

2015-08-22 23:38:01 275

原创 UVa 11624 Fire!

11624 Fire!Joe works in a maze. Unfortunately, portions of the maze have caughton fire, and the owner of the maze neglected to create a fire escape plan.Help Joe escape the maze.Given Joe’s lo

2015-08-22 22:44:27 381

原创 HDU 2612 Find a way

Find a wayTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)HDU 2612 传送Problem DescriptionPass a year learning in Hangzhou, yifenfei arrival hometown Ni

2015-08-22 22:24:24 217

原创 HDU 5115 Dire Wolf 区间DP+记忆化搜索

Dire WolfTime Limit: 5000/5000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others)Total Submission(s): 749 Accepted Submission(s): 438Problem DescriptionDire wolves, also known

2015-08-20 16:05:13 350

原创 LightOJ - 1422 Halloween Costumes 区间DP

Halloween CostumesTime Limit: 2000MS Memory Limit: 32768KB 64bit IO Format: %lld & %lluDescriptionGappu has a very busy weekend ahead of him. Because, next weekend is Halloween, and he is plan

2015-08-19 16:53:38 497

原创 HDU 4612 Warm up 树的最长路径DP + 无向图带重边

Warm upTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Problem Description  N planets are connected by M bidirectional channels that allow instant transporta

2015-08-19 11:33:40 369

原创 HDU 4738Caocao's Bridges 邻接表tarjan 割桥

Caocao's BridgesTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Problem DescriptionCaocao was defeated by Zhuge Liang and Zhou Yu in the battle of Chibi. But

2015-08-15 18:11:05 329

原创 凸包 Graham扫描法

凸包模板函数 Graham扫描法 简单概括就是 排序+扫描#include #include #include #include using namespace std;const int maxn = 20000 ;struct Point { double x,y,len ;}Stack[maxn] , Pt[maxn] , Point_A ;double

2015-08-14 20:29:50 753

原创 ZOJ 3537 Cake 凸包+区间DP+记忆化搜索

Cake--------------------------------------------------------------------------------Time Limit: 1 Second Memory Limit: 32768 KB ------------------------------------------------------------

2015-08-14 19:17:51 409

原创 HDU1160 FatMouse's Speed

FatMouse's SpeedTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)HDU 1160Special JudgeProblem DescriptionFatMouse believes that the fatter a mouse is, the

2015-08-13 20:46:56 224

原创 POJ 2955 brackets

BracketsTime Limit: 1000MS Memory Limit: 65536KDescriptionWe give the following inductive definition of a “regular brackets” sequence:the empty sequence is a regular brackets sequence,if

2015-08-13 20:31:37 290

空空如也

空空如也

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

TA关注的人

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