codeforces 630K - 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的更多相关文章
- codeforces 630K Indivisibility (容斥原理)
IT City company developing computer games decided to upgrade its way to reward its employees. Now it ...
- 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 ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
随机推荐
- 文件I/O之fcntl函数
fcntl函数可以改变已打开的文件的性质. #include <fcntl.h> int fcntl( int filedes, int cmd, ... /* int arg */ ); ...
- 【转】C语言 字符数组与字符串
原文:http://blog.csdn.net/metasearch/article/details/2856097 在C语言编程中,当我们声明一个字符串数组的时候,常常需要把它初始化为空串.总结起来 ...
- iOS之深入了解控制器View的加载
前言 在面试中,面试官可能会问这样的问题,loadView有什么作用,它与viewDidLoad有何区别 首先我们得知道,控制器view是通过懒加载的方式进行加载的,即用到的时候再加载. loadVi ...
- 3D分析之3D要素工具箱(转)
来自:http://blog.csdn.net/kikitamoon/article/details/8193764 整理有关 ArcGIS 10.1 3D分析工具箱中,3D Feature 工具箱中 ...
- Android_Spinner_SimpleAdapter
xml布局文件: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xml ...
- Scala语言专题
Scala基础01:基础语法 Scala基础02:函数,懒值,异常 Scala基础03:数组 Scala基础04:类与对象 Scala基础05:包与引用 Scala基础06:继承 Scala基础07: ...
- 用happen-before规则重新审视DCL(转载)
编写Java多线程程序一直以来都是一件十分困难的事,多线程程序的bug很难测试,DCL(Double Check Lock)就是一个典型,因此对多线程安全的理论分析就显得十分重要,当然这决不是说对多线 ...
- 基于ARM的RealView MDK开发环境
RealView MDK可以对各种嵌入式处理器的软件开发工具.这么高端,着实很吸引我,ADS12还不知道怎么搞,居然还有这么高端的,但是还是得了解一下唉.洗这个自动配 置启动代码,集成Flash烧写模 ...
- 抽象(abstract)升级版变接口(interface) 继承(extends)升级版叫实现(implements) 升级版啊升级版 接口可以多继承
Client --------------------------------------------------- public class Client{ public static void m ...
- 读jQuery官方文档:遍历
遍历 jQuery的快捷遍历方法可以快速定位到想要的元素.查找祖先元素 html<div class="grandparent"> <div class=&quo ...