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 ...
随机推荐
- 第一章 02 谈谈static关键词
引文一下吧 http://blog.csdn.net/hackbuteer1/article/details/7487694 一.static在C语言中的含义 1.静态变量作用范围在一个文件内,程序开 ...
- vb.net中常用键值
可在代码中的任何地方用下列常数代替实际值: 常数 值 描述 vbKeyLButton 0x1 鼠标左键 vbKeyRButton 0x2 鼠标右键 vbKeyCancel 0x3 CANCEL 键 v ...
- marine
- word-wrap,word-break,text-wrap的区别
今晚看到了无双老师关于word-wrap,word-break区别的讲解 http://www.cnblogs.com/2050/archive/2012/08/10/2632256.html 受益 ...
- myeclipse连接数据库遇到的几个问题
1:无效的SQL URL: //将获取的参数插入数据库 Connection conn=null; PreparedStatement stat=null; ...
- Python 基础【第十篇】内置类型
一.integral 类型 Python提供了两种integral类型,即int(整数)与bool(布尔值). 1.1.整数 整数的相关运算符.函数.数据类型转换 1.1.1.整数的运算符 前面已经讲 ...
- 关于Comparator和Comparable
1.Comparable 2.Comparator >>>>>> Comparable & Comparator 都是用来实现集合中元素的比较.排序的,只 ...
- 浅试WebStorm配置Node.js开发环境
web前端开发IDE一直喜欢用WebStorm,这里简单介绍如何用WebStorm搭建一个Node.js开发环境. 首先,需要在本地安装好node.js,以及npm包管理工具.你也可以吧node.js ...
- JDBC入门try/catch型
package com.itheima.domain; import java.sql.Connection; import java.sql.DriverManager; import java.s ...
- Android调用系统相机以及自定义相机
0.综述 自定义相机,此处展示简单的相机功能,官方文档中还有相应关于视频拍摄的内容,此处不提 1.添加权限 <!--相机权限,数据存储--> <uses-permission and ...