hdu 1220 容斥】的更多相关文章

http://acm.hdu.edu.cn/showproblem.php?pid=1220 Cube Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2260    Accepted Submission(s): 1819 Problem Description Cowl is good at solving math problems…
问a,b区间内与n互质个数,a,b<=1e15,n<=1e9 n才1e9考虑分解对因子的组合进行容斥,因为19个最小的不同素数乘积即已大于LL了,枚举状态复杂度不会很高.然后差分就好了. /** @Date : 2017-09-28 16:52:30 * @FileName: HDU 4135 容斥.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/…
$n,m <= 1e5$ ,$i<=n$,$j<=m$,求$(i⊥j)$对数 /** @Date : 2017-09-26 23:01:05 * @FileName: HDU 2841 容斥 或 反演.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/ * @Version : $Id$ */ #include <bits/stdc++.h…
又是求gcd=k的题,稍微有点不同的是,(i,j)有偏序关系,直接分块好像会出现问题,还好数据规模很小,直接暴力求就行了. /** @Date : 2017-09-15 18:21:35 * @FileName: HDU 1695 容斥 或 莫比乌斯反演.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/ * @Version : $Id$ */ #in…
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #define LL long long using namespace std; ; ; LL Factor[],cnt,n,m,tot,Rev,Kase,Prime[Maxn]; bool vis[Maxn]; inline LL Quick_Pow(LL x,LL y) { LL Ret=; whi…
Code: #include<cstdio> #include<cstring> #include<cmath> #include<iostream> using namespace std; const int maxn=100000+233; typedef long long ll; int v[maxn],vis[maxn]; int m[maxn]; int num; //质因子个数 ll ans=0; ll A,B; ll gcd(ll a,ll…
Code: #include<cstdio> using namespace std; typedef long long ll; const int R=13; ll a[R]; ll n,ans; int m,cnt=0; ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);} void dfs(int cur,ll lcm,int id){ if(cur>cnt)return; lcm=a[cur]/gcd(a[cur],lcm)*lcm; if(…
hdu 5792 要找的无非就是一个上升的仅有两个的序列和一个下降的仅有两个的序列,按照容斥的思想,肯定就是所有的上升的乘以所有的下降的,然后再减去重复的情况. 先用树状数组求出lx[i](在第 i 个数左边的数中比它小的数的个数),ld[i](在第 i 个数左边的数中比它大的数的个数),rx[i](在第 i 个数右边的数中比它小的数的个数) ,rd[i](在第 i 个数右边的数中比它大的数的个数).然后重复的情况无非就是题目中a与c重合(rx[i]*rd[i]),a与d重合(rd[i]*ld[…
GCD 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=1695 Description Given 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD(x, y) = k. GCD(x, y) means the greatest common divisor of x and y. Since the number of choices may be…
A Simple Chess 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5794 Description There is a n×m board, a chess want to go to the position (n,m) from the position (1,1). The chess is able to go to position (x2,y2) from the position (x1,y1), only and if…