K. Indivisibility

题意:给一个n(1 <= n <= 10^18)的区间,问区间中有多少个数不能被2~10这些数整除;

整除只需要看素数即可,只有2,3,5,7四个素数;基本的容斥原理;数据很小直接用二进制模拟了;

int main()
{
ll n,a[] = {,,,};
scanf("%I64d",&n);
ll cnt = n;
for(int id = ;id < (<<);id++){
int num = ;
rep0(i,,)if(id &(<<i)){
num *= a[i];
}
int t = ;
if(__builtin_popcount(id) & ) t = -;
cnt += 1LL*t*(n/num);
}
cout<<cnt;
return ;
}

codeforces 630K - Indivisibility的更多相关文章

  1. codeforces 630K Indivisibility (容斥原理)

    IT City company developing computer games decided to upgrade its way to reward its employees. Now it ...

  2. Experimental Educational Round: VolBIT Formulas Blitz K. Indivisibility —— 容斥原理

    题目链接:http://codeforces.com/contest/630/problem/K K. Indivisibility time limit per test 0.5 seconds m ...

  3. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  4. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  5. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  6. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  7. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  8. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  9. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

随机推荐

  1. 23、从头学Android之ContentProvider .

    http://blog.csdn.net/jiahui524/article/details/7016430 应用场景: 在Android官方指出的Android的数据存储方式总共有五种,分别是:Sh ...

  2. java_spring_依赖注入

    IOC反转控制 PersonService属性 PersonDao personDao接受通过xml注入的对象 PersonDaoBean.  Person中save()调用 PersonDaoBea ...

  3. Redis主备自动切换

    Sentinel(哨兵)是用于监控redis集群中Master状态的工具. 一.Sentinel作用  1.Master状态检测   2.如果Master异常,则会进行Master-Slave切换,将 ...

  4. 【原】Spring与MongoDB集成:配置

    MongoDB的API提供了DBObject接口来实现BSONObject的操作方法,BasicDBObject是具体实现.但是并没有提供DBObject与BeanObject的转换.在还没有了解到与 ...

  5. 用js对象创建链表

    //以下是一个链表类 function LinkedList(){ //Node表示要加入列表的项 var Node=function(element){ this.element=element; ...

  6. CSS实现半透明的方法

    IE8不支持以前{filter:alpha(opacity=50);}的私有属性, 转而支持更规范的私有属性-ms-filter: “progid:DXImageTransform.Microsoft ...

  7. MySQL高可用解决方案(MySQL HA Solution)

    http://blog.sina.com.cn/s/blog_7e89c3f501012vtr.html 什么是高可用性?很多公司的服务都是24小时*365天不间断的.比如Call Center.这就 ...

  8. java.util.concurrent 多线程框架

    http://daoger.iteye.com/blog/142485 JDK5中的一个亮点就是将Doug Lea的并发库引入到Java标准库中.Doug Lea确实是一个牛人,能教书,能出书,能编码 ...

  9. Android中FTP服务器搭建入门

    http://www.2cto.com/kf/201501/374048.html http://blog.csdn.net/smile3670/article/details/44343617  有 ...

  10. ###《Machine Learning》by Andrew NG

    点击查看Evernote原文. #@author: gr #@date: 2014-10-17 #@email: forgerui@gmail.com Fundamental 一. 矩阵的迹.秩 矩阵 ...