IT City company developing computer games decided to upgrade its way to reward its employees. Now it looks the following way. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each t…
K. Indivisibility 题意:给一个n(1 <= n <= 10^18)的区间,问区间中有多少个数不能被2~10这些数整除: 整除只需要看素数即可,只有2,3,5,7四个素数:基本的容斥原理:数据很小直接用二进制模拟了: int main() { ll n,a[] = {,,,}; scanf("%I64d",&n); ll cnt = n; ;id < (<<);id++){ ; rep0(i,,)<<i)){ num *…
题目链接:http://codeforces.com/contest/630/problem/K K. Indivisibility time limit per test 0.5 seconds memory limit per test 64 megabytes input standard input output standard output IT City company developing computer games decided to upgrade its way to…
K. Indivisibility time limit per test 0.5 seconds memory limit per test 64 megabytes input standard input output standard output IT City company developing computer games decided to upgrade its way to reward its employees. Now it looks the following…
题意: 给n个正整数,求有多少个GCD为1的子序列.答案对1e9+7取模. 1<=n<=1e5,数字ai满足1<=ai<=1e5 分析: 设f(x)表示以x为公约数的子序列个数 那么ans=f(1)- Σf(pi) + Σf(pi*pj) - Σf(pi*pj*pk) ........ 注意到对于一个f(x),它对结果的贡献是: 若x为合数,那么前面系数为0 若x由奇数个素数组成,那么系数是-1 若x由偶数个素数组成,那么系数是1 这明显就是莫比乌斯函数……直接一个线性筛出来 那么…
hdu4135 求[L,R]范围内与N互质的数的个数. 分别求[1,L]和[1,R]和n互质的个数,求差. 利用容斥原理求解. 二进制枚举每一种质数的组合,奇加偶减. #include <bits/stdc++.h> using namespace std; typedef long long ll; ; int fac[N], cnt; void factor(int n) { cnt = ; int limit = sqrt(n); ; i <= limit; ++i) { ) fa…
题目链接:Codeforces 451E Devu and Flowers 题目大意:有n个花坛.要选s支花,每一个花坛有f[i]支花.同一个花坛的花颜色同样,不同花坛的花颜色不同,问说能够有多少种组合. 解题思路:2n的状态,枚举说那些花坛的花取超过了,剩下的用C(n−1sum+n−1)隔板法计算个数.注意奇数的位置要用减的.偶数的位置用加的.容斥原理. #include <cstdio> #include <cstring> #include <cmath> #in…
A. Joysticks time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at…
题目链接:http://codeforces.com/contest/340/problem/E E. Iahub and Permutations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Iahub is so happy about inventing bubble sort graphs that he's sta…
Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n soldiers. While the rest of the world is fighting for the Iron Throne, he is going to get ready for the attack of the White Walkers. He has created a m…