自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 多重背包(二进制优化)hdu 1059

#include<bits/stdc++.h>const int maxn = 500000;typedef long long ll;using namespace std;int dp[maxn],n[7],a[maxn];int main(){ int cnt=1; while(scanf("%d %d %d %d %d %d",&n[1],...

2018-11-06 20:47:42 144

原创 Hdu1087 Poj1458 Hdu 2602

Super Jumping! Jumping! Jumping! Hdu1087#include<bits/stdc++.h>const int maxn = 1005;typedef long long ll;using namespace std;ll dp[maxn],a[maxn];int main(){ int n; while(scanf(...

2018-11-06 14:30:33 156

转载 01背包详解

背包问题是动态规划(dp)的一种,但是它的解法相对来说比较特别,所以我们把它单独列出来学习和分析,但是它的基本思想还是dp。关于概念就不多说了,大家可以参考我以上所提到的资料,上面对概念的讲解都是比较独到和权威的。  而01背包是最典型最基础的背包问题,它的基本模型为:    有一个容量为v的背包,现在有n件价值为value[i],体积为volume[i]的物品(i为第i件),问怎么样放才...

2018-11-05 11:02:08 400

原创 xyz 的fft 模板

这是我在找的比较好用的,适用情况广,比较清晰的fft模板了!#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <math.h>using namespace std;const double PI =...

2018-10-08 13:49:40 206

原创 HDU6265(能被n整除的因子与其欧拉乘积的和)

由这两个公式联立公式很显然我们可以消去d可以推出:我们知道对于每个pi,我们都有qi种取法,根据欧拉函数的性质我们知道每一个质数的的倍数的欧拉函数值 都等于这个质数的欧拉函数值等于其扩大的倍数,正好其外面缩小倍数也为其欧拉扩大的倍数,所以这组数对答案的贡献是相同的。我们可以通过类比的方法得到所有的答案:我们可以通过已经给的质因子知道他一共有多少因子,通过欧拉函数的性质我们可以将对答案贡...

2018-10-05 20:58:42 1142

原创 我的第一道杜教筛(莫比乌斯函数求和 51Nod-1244)

先总结一下,杜教筛的的精髓之处我认为在于通过两个积性函数做狄利克雷卷积以后就可以对其进行整除分块了,又因为一般用到杜教筛的题目数据量都特别大,是o(n)时间都跑不过来的数据,所以肯定不能预处理。但是这样的题样例数量不会太大,你只能每一次都计算结果,不能与处理出来结果,所以你需要用到记忆化搜索或hashmap去存整除分块的过程中出现的s(n)。以后用到s(n)可以o(sqrt(n))查询调用。记...

2018-10-04 11:26:57 312

原创 经典小知识融合数论题(hdu-5528)

B - Count a * b HDU - 5528 Marry likes to count the number of ways to choose two non-negative integers a and b less than m to make a×b mod m≠0.Let's denote f(m) as the number of ways to choose tw...

2018-10-02 16:04:35 288

原创 逆元的几种求法

1、快速幂直接求(要求取模的数为质数)由费马小定理可得,如果p为质数,则a^(p-1)%c=1=a*a^(p-2)%c;如果a*b%mod=1;则a为b的逆元,b也为a的逆元。a的逆元为a^(mod-2).ll pow_mod(ll a,ll b){  ll res=1;  while(b){  if(b&1) res=res*a%mod;  b...

2018-10-01 10:49:17 1117

原创 另类容斥和欧拉函数巧妙应用(HDU--5514)

There are mm stones lying on a circle, and nn frogs are jumping over them. The stones are numbered from 00 to m−1m−1 and the frogs are numbered from 11 to nn. The ii-th frog can jump over exactly aia...

2018-09-30 20:18:39 162

原创 莫比乌斯函数的求法

sqrt(n)求解莫比乌斯函数值,如果把素数筛出来会使求解莫比乌斯函数更快。ll getmu(ll n){    ll v=1;    for(int i=2;i*i<=n;i++)     if(n%i==0)     {        v=-v;n/=i;        if(n%i==0)return 0;     }    if(n!=1)v=-v;    r...

2018-09-28 15:53:50 1183

原创 异或和与组合数(HDU - 4810)按二进制位拆分

Ms.Fang loves painting very much. She paints GFW(Great Funny Wall) every day. Every day before painting, she produces a wonderful color of pigments by mixing water and some bags of pigments. On the K-...

2018-09-24 20:21:48 558

原创 xyz的计算圆与多边形相交面积模板

#include<bits/stdc++.h> using namespace std; const double eps = 1e-8;const double PI = acos(-1.0); int dcmp(double x){//判断误差在eps范围内     if( x > eps ) return 1;    return x < -eps...

2018-09-20 09:56:27 514

原创 xyz的向量旋转模板

#include<iostream>#include<algorithm>#include<stdio.h>#include<math.h>#include<cstring>#include<string> #define inf 0x3f3f3f3f#define pi acos(-1.0)#define...

2018-09-18 09:54:53 905

原创 莫比乌斯反演前缀和除法分块优化(hdu4746)

C - Mophues HDU - 4746 As we know, any positive integer C ( C >= 2 ) can be written as the multiply of some prime numbers:     C = p1×p2× p3× ... × pk which p1, p2 ... pk are all prime number...

2018-09-17 10:50:59 266

原创 xyz的判断点在凸包内模板

int n,m,tot;struct point {    double x,y;}p[100000],a[100000],ss;bool cmp(point A,point B){    if(A.x!=B.x)    return A.x<B.x;    return A.y<B.y;}point operator -(point A,point B){...

2018-09-14 21:52:24 391 2

原创 xyz的凸包模板

const int N=10001;struct point{    int x;    int y;}p[N],q[N];int n,per[N],l;inline point getmag(point a,point b){    point s;    s.x=b.x-a.x;s.y=b.y-a.y;    return s;}inline int multiX(po...

2018-09-14 21:49:28 187

原创 判断lcm超过ll 和开n次方根的精确值

判断x开pos次方根的精确值:用pow(x,1/pos)开的话,每次开平方根都是保留的整数。会导致精度的缺失,当pos大的话开出来的值就会出现误差。但误差一般在开出来的值 与正确答案的误差在|1|以内。ll qpow(ll a, ll b) {//快速幂    ll ans = 1;    while(b) {        if(b&1) {            doubl...

2018-09-12 15:24:21 153

原创 2018 ICPC 沈阳网络赛 G. Spare Tire 1到n中与m互质的平方和与本身和

计蒜客全部课程  学习计划 题库 比赛 Spare Tire编辑代码 15.27%  1000ms  131072KA sequence of integer \lbrace a_n \rbrace{an​} can be expressed as: \displaystyle a_n = \left\{ \begin{array}{lr} 0, & n=...

2018-09-08 22:12:02 255

原创 gcd的小特性

由UVA - 11426学到的小知识由于数据量为4×le6,我们暴力跑答案不算gcd的时间的话还要1e13。大致需要10000s.所以我们需要预处理一些值。直接就往分块想,我们知道gcd(1,n)、 gcd(2,n)……………gcd(n-1,n)里有很多对的gcd是相同的。而gcd(x,n)=i等价于gcd(x/i,n/i)=1,因此gcd为i的个数为phi(n/i)。因此我们可以通过...

2018-09-02 19:54:17 474

原创 2018ICPC南京网络赛(线性筛预处理与整除分块)J题sum

 1000ms 512000KA square-free integer is an integer which is indivisible by any square number except 11. For example, 6 = 2 * 3=1⋅6 is square-free, but 12 = 2^2 *3 is not, because 2^2 is a square num...

2018-09-02 12:56:28 194

原创 区间素数筛

LightOJ - 1197 Amakusa, the evil spiritual leader has captured the beautiful princess Nakururu. The reason behind this is he had a little problem with Hanzo Hattori, the best ninja and the love of N...

2018-08-31 22:13:12 137

原创 调和级数与整除分块

LightOJ - 1234(保留小数)In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers:In this problem, you are given n, you have to find Hn.InputInput st...

2018-08-28 09:43:28 277

原创 按位枚举玄学贪心--莫名其妙过题

Problem J. CSGOTime Limit: 4000/2000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 694    Accepted Submission(s): 363 Problem DescriptionYou are playing C...

2018-08-24 17:17:01 195

原创 牛客第9场-E 概率dp

把概率dp当数学题做推公式,也是我太菜了。最重要是我还津津有味推了一下午。刚一开始我想到枚举对的题数,从n到0跑一遍,预处理出来全部发生的概率pp。然后通过当 对的题数为n时 :  序列全部连续       得分为     pp * n^m.当对的题数为n-1时:  我们要判断错的那个题在什么位置   得分为累积和: 令i从1到n,  pp*(100-p[i])/p[i] * [(i-...

2018-08-16 21:43:41 255

原创 求解欧拉函数的值

没有优化之前的求欧拉函数的代码(时间复杂度为o(n))#include<stdio.h>#include<iostream>using namespace std;long long  phi(long long n){    long long ans=n;    for(int i=2;i<=n;i++)    if(n%i==0)    {...

2018-08-03 15:55:25 478

原创 01分数规划简单变形应用

01分数规划是这样的一类问题,有一堆物品,每一个物品有一个收益ai,一个代价bi,我们要求一个方案使选择的∑ai/∑bi∑ai/∑bi最大。两种做法:1、二分不断迫近答案    2、在前一个解的基础上精确下一个解模板如下(例题为2018牛客网多校第5场A题)1、二分求解struct node{    double s,c,ans;}cur[MAXN];bool cmp(d...

2018-08-02 21:24:52 179

空空如也

空空如也

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

TA关注的人

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