- 博客(18)
- 收藏
- 关注
原创 Marriage Match II HDU - 3081 (二分答案+最大流+并查集)
Presumably, you all have known the question of stable marriage match. A girl will choose a boy; it is similar as the game of playing house we used to play when we are kids. What a happy time as so many
2017-10-30 18:14:36 252
原创 Task Schedule HDU - 3572(dinic最大流)
Our geometry princess XMM has stoped her study in computational geometry to concentrate on her newly opened factory. Her factory has introduced M new machines in order to process the coming N tasks. Fo
2017-10-29 00:04:03 240
原创 最小花费最大流模板
自己写的最小花费最大流模板#include<iostream>#include<cstdio>#include<cmath>#include<cstring>#include<queue>using namespace std;const int maxn=10010;//点数const int maxx=100100;//边数,注意为实际上边数的两倍const int INF=1<
2017-10-25 11:40:30 260
原创 Going Home HDU - 1533(最小费用最大流)
On a grid map there are n little men and n houses. In each unit time, every little man can move one unit step, either horizontally, or vertically, to an adjacent point. For each little man, you need to
2017-10-25 00:04:37 244
原创 1到n对于质数p的逆元的线性筛
1到n对于质数p的逆元inv[1]=1;for(int i=2;i<=n;i++) inv[i]=(p-p/i)*inv[p%i]%p;质求单个数的逆元,当然费马小定理也可以 时间复杂度相同int Get_inv(int n){ if(n==1) return 1; return (p-p/n)*(Get_inv(p%n))%p;}
2017-10-24 23:43:43 918
原创 Color UVALive - 7040 (容斥+组合数)
Recently, Mr. Big recieved n owers from his fans. He wants to recolor those owers with m colors. The owers are put in a line. It is not allowed to color any adjacent owers with the same color. Flowers
2017-10-24 23:38:25 301
原创 Josephus again HDU - 3089 (约瑟夫环问题)
In our Jesephus game, we start with n people numbered 1 to n around a circle, and we eliminated every k remaining person until only one survives. For example, here’s the starting configuration for n =
2017-10-23 20:18:11 496 3
原创 TrickGCD HDU - 6053(莫比乌斯函数与容斥的关系)
You are given an array AA , and Zhu wants to know there are how many different array BB satisfy the following conditions? 1≤Bi≤Ai For each pair( l , r ) (1≤l≤r≤n) , gcd(bl,bl+1…br)≥2 Input The firs
2017-10-22 15:26:28 435
原创 Gcd表中的质数 51Nod - 1192 (莫比乌斯反演)
有一个M * N的表格,行与列分别是1 - M和1 - N,格子中间写着行与列的最大公约数Gcd(i, j)(1 <= i <= M, 1 <= j <= N)。 例如:M = 5, n = 4。1 2 3 4 5 1 1 1 1 1 1 2 1 2 1 2 1 3 1 1 3 1 1 4 1 2 1 4 1给出M和N,求这张表中有多少个质数。 Input 第1行:一个数T,表示后面用
2017-10-21 01:48:07 472
原创 Sum Of Gcd HDU - 4676(莫队)
Given you a sequence of number a 1, a 2, …, a n, which is a permutation of 1…n. You need to answer some queries, each with the following format: Give you two numbers L, R, you should calculate sum
2017-10-20 16:07:59 299
原创 最小公倍数之和 V2 51Nod - 1190(莫比乌斯反演)
给出2个数a, b,求LCM(a,b) + LCM(a+1,b) + .. + LCM(b,b)。 例如:a = 1, b = 6,1,2,3,4,5,6 同6的最小公倍数分别为6,6,6,12,30,6,加在一起 = 66。 由于结果可能很大,输出Mod 10^9 + 7的结果。(测试数据为随机数据,没有构造特别坑人的Test) Input 第1行:一个数T,表示后面用作输入测试的数的数量
2017-10-19 15:57:41 325
原创 Number Theory (Easy) SPOJ - NUMTRYE(数论)(结论类)
f(n) and g(n) are two functions defined as following :f(n)=∏(pi2ei+1+1)f(n) = ∏( pi^{2e_i+1}+1 ), where pi is prime factor of n and ei is highest power of pi in n.g(n)=Σ(ngcd(n,i))g(n) = Σ( \frac{n}{gc
2017-10-18 12:42:39 307
原创 无法表示的数 51Nod - 1176
z = (x/2)取整后 + y + xy,x,y都是大于0的整数。z=[x2]+y+xyz=[\frac{x}{2}]+y+xyx,y取不同的数,z可能有多种表示方式,也可能一种都没有,比如3,15就无法用任何x,y来表示。现在将所有无法表示的数排个序,组成一个序列S,给出一个整数n,你来求Snn = ?。比如n = 1,Snn = 1,n = 2,Snn = 3……,由于Snn可能很大,只输出
2017-10-18 00:25:12 342
原创 HeHe HDU - 2879(积性)
In the equation X^2≡X(mod N) where x∈[0,N-1], we define He[N] as the number of solutions. And furthermore, define HeHe[N]=He[1]*……*He[N] Now here is the problem, write a program, output HeHe[N] mod
2017-10-17 23:54:55 297
原创 Digital Square HDU - 4394 (数论)(DFS)
Given an integer N,you should come up with the minimum nonnegative integer M.M meets the follow condition: M2mod10x=nM^2 mod 10^x=n(x=0,1,2,3….) Input The first line has an integer T( T< = 1000), th
2017-10-16 00:18:10 307
原创 Diophantus of Alexandria HDU - 1299(数论)
Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first mathematicians to study equations where variables were restricted to integral values. In honor of him,
2017-10-12 23:01:56 256
原创 Aragorn's Story HDU - 3966(树链剖分)
Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies who want to invade his kingdom. As Aragorn knows, the enemy has N camps out
2017-10-09 23:25:25 229
原创 Query on a tree SPOJ - QTREE(树链剖分)
传送门 题意:给定一棵树,告诉了每条边的权值,然后给出两种操作: (1)把第i条边的权值改为val (2)询问a,b路径上权值最大的边 假期之后的第一篇题解,只学习了一种新的数据结构,树链剖分,此题为入门题,这个我算是学习的最晚的一个人了。这个有种调用了线段的API的感觉#include<cstdio>#include<cstring>#include<algorithm>#inclu
2017-10-09 15:48:12 311
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人