Experimental Educational Round: VolBIT Formulas Blitz K. Indivisibility —— 容斥原理
题目链接:http://codeforces.com/contest/630/problem/K
0.5 seconds
64 megabytes
standard input
standard output
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 transaction.
Every time when the next number of sales is not divisible by any number from 2 to 10 every
developer of this game gets a small bonus.
A game designer Petya knows that the company is just about to release a new game that was partly developed by him. On the basis of his experience he predicts that n people
will buy the game during the first month. Now Petya wants to determine how many times he will get the bonus. Help him to know it.
The only line of the input contains one integer n (1 ≤ n ≤ 1018)
— the prediction on the number of people who will buy the game.
Output one integer showing how many numbers from 1 to n are
not divisible by any number from 2 to 10.
12
2
题解:
实际上是除去2,3,5,7的倍数,容斥原理。
代码如下:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double eps = 1e-;
const int INF = 2e9;
const LL LNF = 9e18;
const int mod = 1e9+;
const int maxn = 1e3+; int main()
{
LL n;
cin>>n;
LL ans = , a[] = {,,,};
for(int s = ; s<(<<); s++)
{
LL cnt = , val = ;
for(int j = ; j<; j++)
if((<<j)&s)
{
cnt++;
val *= a[j];
}
ans += (cnt&)? (n/val):(-n/val);
}
cout << n-ans <<endl;
}
Experimental Educational Round: VolBIT Formulas Blitz K. Indivisibility —— 容斥原理的更多相关文章
- Experimental Educational Round: VolBIT Formulas Blitz K
Description IT City company developing computer games decided to upgrade its way to reward its emplo ...
- Experimental Educational Round: VolBIT Formulas Blitz
cf的一次数学场... 递推 C 题意:长度<=n的数只含有7或8的个数 分析:每一位都有2种可能,累加不同长度的方案数就是总方案数 组合 G 题意:将5个苹果和3个梨放进n个不同的盒子里的方案 ...
- Experimental Educational Round: VolBIT Formulas Blitz N
Description The Department of economic development of IT City created a model of city development ti ...
- Experimental Educational Round: VolBIT Formulas Blitz J
Description IT City company developing computer games invented a new way to reward its employees. Af ...
- Experimental Educational Round: VolBIT Formulas Blitz F
Description One company of IT City decided to create a group of innovative developments consisting f ...
- Experimental Educational Round: VolBIT Formulas Blitz D
Description After a probationary period in the game development company of IT City Petya was include ...
- Experimental Educational Round: VolBIT Formulas Blitz C
Description The numbers of all offices in the new building of the Tax Office of IT City will have lu ...
- Experimental Educational Round: VolBIT Formulas Blitz B
Description The city administration of IT City decided to fix up a symbol of scientific and technica ...
- Experimental Educational Round: VolBIT Formulas Blitz A
Description The HR manager was disappointed again. The last applicant failed the interview the same ...
随机推荐
- 第四期coding_group笔记_用CRF实现分词-词性标注
一.背景知识 1.1 什么是分词? NLP的基础任务分为三个部分,词法分析.句法分析和语义分析,其中词法分析中有一种方法叫Tokenization,对汉字以字为单位进行处理叫做分词. Example ...
- 赞一下TMS Software 和 AdvStringGrid
非常久前给Support发Email问能不能在设计期给AdvStringGrid标题加个数字标识.每次我都是自己改代码加上去.这次升级到新版本号,没想到增加了这个功能: 功能虽小可是非常有用,非常多的 ...
- sdut 面向对象程序设计上机练习九(对象指针)
面向对象程序设计上机练习九(对象指针) Time Limit: 1000MS Memory limit: 65536K 题目描写叙述 建立对象数组,内放5个学生数据(学号是字符串类型.成绩是整型).设 ...
- TDDL-剖析淘宝TDDL
TDDL-剖析淘宝TDDL 学习了:https://blog.csdn.net/sumj7011/article/details/78286741 Taobao Distribute Data Lay ...
- 转: linux下的自动对时
转自: http://www.cnblogs.com/vimmer/archive/2012/05/17/2505785.html 评注:date 命令格式为: date -s 2012-08-02 ...
- angular - 小结
引入样式: 导入全局 - >styles.css 导入第三方 - > 在package.json配置,然后再 npm install 安装好以后,最后再angular.json里面的sty ...
- Cocos2d-x初识
cocos2d-x引擎是什么 在学习游戏的时候就有意的搜索这方面的知识,知道游戏须要游戏引擎,引擎听着非常厉害,只是就是一个游戏框架. 或许某一个游戏框架火起来了,就非常流行了,只是我觉得不论什么游戏 ...
- HDU 3435A new Graph Game(网络流之最小费用流)
题目地址:HDU 3435 这题刚上来一看,感觉毫无头绪. .再细致想想.. 发现跟我做的前两道费用流的题是差点儿相同的. 能够往那上面转换. 建图基本差点儿相同.仅仅只是这里是无向图.建图依旧是拆点 ...
- Amazon SNS移动推送更新——新增百度云推送和Windows平台支持
Amazon SNS(Simple Notification Service)是一种基于云平台的消息通知和推送服务. SNS提供简单的 Web 服务接口和基于浏览器的管理控制台让用户可以简易设置.执行 ...
- Thunderbolt雷电接口
官网:https://thunderbolttechnology.net/tech/certification