- 博客(11)
- 收藏
- 关注
原创 树状数组
ll lowbit(ll x){ return x&-x;}void add(ll i,ll x){ while(i<=n){ c[i]+=x; i+=lowbit(i); }}ll query(ll x){ ll ans=0; while(x>0){ ans+=c[x]; x-=lowb
2017-04-27 21:27:19 150
原创 「模版」RMQ+ST表
RMQ+ Sparse Table(稀疏表)实现模版#include "stdio.h"#include "math.h"#define MAXN 100#define max(a,b) (a > b ? a : b)const int num[MAXN];int dp[MAXN][20];void create_max (int n) { int i,j,t; for
2017-04-25 22:35:41 188
原创 分治法 or BIT 求逆序对
方法1: 求逆序对可以利用归并排序来求,其实就是分治。 归并排序在排序过程很中对于一样的数比较是不会改变次序的,因而可以用来求逆序对。 代码如下: 1 #include<stdio.h> 2 3 void Merge(int ,int ,int ); 4 void mergeSort(int ,int ); 5 6 int ch[20000],temp[20000]; 7 in
2017-04-25 20:19:38 494
原创 CCPC 2016-2017 Finals - B
B-WashMr.Panda is about to engage in his favourite activity doing laundry! He’s brought L indistinguishable loads of laundry to his local laundromat, which has N washing machines and M dryers.The ithit
2017-04-25 20:05:52 1033
原创 Lattice Point or Not
扩展欧几里德(ExGCD)Now a days a very common problem is:“The coordinate of two points in Cartesian coordinate system is (200, 300) and(4000, 5000). If these two points are connected we get a line segment. How
2017-04-23 22:05:06 235
原创 13th浙江省赛K Highway Project
Highway ProjectEdward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities from the capital as fast as possible. Thus, he proposed the highway
2017-04-19 19:03:44 262
原创 Hihocoder 1284 机会渺茫
机会渺茫小Hi最近在追求一名学数学的女生小Z。小Z其实是想拒绝他的,但是找不到好的说辞,于是提出了这样的要求:对于给定的两个正整数N和M,小Hi随机选取一个N的约数N’,小Z随机选取一个M的约数M’,如果N’和M’相等,她就答应小Hi。小Z让小Hi去编写这个随机程序,到时候她review过没有问题了就可以抽签了。但是小Hi写着写着,却越来越觉得机会渺茫。那么问题来了,小Hi能够追到小Z的几率是多少呢
2017-04-19 09:20:27 349
原创 Huffman Code 编码译码
赫夫曼编码在通讯中应用广泛,赫夫曼树的建树实际上是一个贪心过程,根据所给的字符权值,优先选取权值小的建树,这样子到最后就可以缩短电文的长度。e.g.如果有A~H八个字符编码,如下图: 实现如下:#include <algorithm>#include <bitset>#include <cassert>#include <climits>#include <cmath>#include
2017-04-19 08:35:51 407
原创 dijkstra+SPFA+Floyd
图论基础算法NO.1 Floyd(多源最短路) 数据结构:邻接矩阵 特点:数据规模不能大(<1000)复杂度O(n^3) 五行代码://Floydvoid floyd(){ for(int k=0;k<n;k++){ for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ dp[
2017-04-13 18:18:18 379
原创 简单模拟
B. Books time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output When Valera has got some free time, he goes to the library to read some books. To
2017-04-09 12:16:29 291
原创 贪心+优先队列(需优化) POJ2010
Moo University - Financial AidBessie noted that although humans have many universities they can attend, cows have none. To remedy this problem, she and her fellow cows formed a new university called Th
2017-04-02 16:29:01 345
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人