Codeforces--630K--Indivisibility(容斥)
Indivisibility
Crawling in process...
Crawling failed
Time Limit:500MS
Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Description
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.
Input
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
Output one integer showing how many numbers from 1 to
n are not divisible by any number from
2 to 10.
Sample Input
12
2
求1--n之间有多少个数可以不被2--10中的任何一个数整除,首先2--10中的数可以由2,3,5,7中的几个数组合表示,所以n/2+n/3+n/5+n/7包含需要的所有的数,但是其中也有重合的部分,比如12是2,3,的倍数,所以需要从2,3,5,7中任取2--4个数进行组合,去除重复的
#include<iostream>
using namespace std;
int main()
{
__int64 n;
while(cin>>n)
{
__int64 m=n/2+n/3+n/5+n/7-n/6-n/10-n/14-n/15
-n/21-n/35+n/30+n/70+n/42+n/105-n/210;
m=n-m;
cout<<m<<endl;
}
return 0;
}
Codeforces--630K--Indivisibility(容斥)的更多相关文章
- Codeforces.348D.Turtles(容斥 LGV定理 DP)
题目链接 \(Description\) 给定\(n*m\)的网格,有些格子不能走.求有多少种从\((1,1)\)走到\((n,m)\)的两条不相交路径. \(n,m\leq 3000\). \(So ...
- codeforces 630K - Indivisibility
K. Indivisibility 题意:给一个n(1 <= n <= 10^18)的区间,问区间中有多少个数不能被2~10这些数整除: 整除只需要看素数即可,只有2,3,5,7四个素数: ...
- codeforces 466C 计数 codeforces 483B 二分 容斥
题意:给你n个数,将他们分成连续的三个部分使得每个部分的和相同,求出分法的种数. 思路:用一个数组a[i]记下从第一个点到当前i点的总和.最后一个点是总和为sum的点,只需求出总和为1/3sum的点和 ...
- codeforces 449D DP+容斥
Jzzhu and Numbers Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u ...
- codeforces 630K Indivisibility (容斥原理)
IT City company developing computer games decided to upgrade its way to reward its employees. Now it ...
- Codeforces 100548F - Color (组合数+容斥)
题目链接:http://codeforces.com/gym/100548/attachments 有n个物品 m种颜色,要求你只用k种颜色,且相邻物品的颜色不能相同,问你有多少种方案. 从m种颜色选 ...
- Codeforces Round #330 (Div. 2) B. Pasha and Phone 容斥定理
B. Pasha and Phone Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/pr ...
- Codeforces 803F Coprime Subsequences (容斥)
Link:http://codeforces.com/contest/803/problem/F 题意:给n个数字,求有多少个GCD为1的子序列. 题解:容斥!比赛时能写出来真是炒鸡开森啊! num[ ...
- Codeforces Round #258 (Div. 2) E. Devu and Flowers 容斥
E. Devu and Flowers 题目连接: http://codeforces.com/contest/451/problem/E Description Devu wants to deco ...
- Codeforces Round #258 (Div. 2) 容斥+Lucas
题目链接: http://codeforces.com/problemset/problem/451/E E. Devu and Flowers time limit per test4 second ...
随机推荐
- 开发日记(项目中SQL查询的优化)
今天发现自己之前写的一些SQL查询在执行效率方面非常不理想,于是尝试做了些改进. 需求为查询国地税表和税源表中,国税有而税源没有的条目数,之前的查询如下: SELECT COUNT(NAME) ...
- 移动web——touch事件应用
基本概况 1.touch事件在移动端被用来代替click事件,因为click事件的触发会延迟影响了用户体验 2.touch事件还可以与translate构成吸附效果 3.现行有一种排版方式是左边宽度是 ...
- 六时出行 App 隐私政策
六时出行 App 隐私政策 本应用尊重并保护所有使用服务用户的个人隐私权.为了给您提供更准确.更有个性化的服务,本应用会按照本隐私权政策的规定使用和披露您的个人信息.但本应用将以高度的勤勉.审慎义 ...
- java实例1
1.满天星星 import java.awt.*; public class xinxin { public static void main(String[] args) { Frame w = n ...
- Cesium学习笔记(九):导入3D模型(obj转gltf)
在用cesium的过程中难免需要导入别人做好的3D模型,这时候就需要将这些模型转成gltf格式了 当然,官方也给了我们一个网页版的转换器,但是毕竟是网页版的,效率极其低下,文件还不能太大,所以我们就需 ...
- 如何让字体大小<12px
transform:scale( ) -webkit-transform:scale( )
- node版本管理工具nvm安装使用教程
一些安装包依赖一定的node版本,可以采用nvm管理node, 可以快速的进行版本切换. 操作系统: windows10, x64 常见版本工具: 1. nvmw, nvmm install node ...
- Array.prototype.slice.call()的理解
最近在看廖雪峰的JS课程,浏览器中的操作DOM的那一章,有这样一道题. JavaScript Swift HTML ANSI C CSS DirectX <!-- HTML结构 --> & ...
- 猜数字游戏的提示(Master-Mind Hints, UVa 340)
实现一个经典"猜数字"游戏. 给定答案序列和用户猜的序列,统计有多少数字位置正确 (A),有多少数字在两个序列都出现过但位置不对(B). 输入包含多组数据.每组输入第一行为序列长度 ...
- OI数学知识清单
OI常用的数学知识总结 本文持续更新…… 总结一下OI中的玄学知识 先列个单子,(from秦神 数论 模意义下的基本运算和欧拉定理 筛素数和判定素数欧几里得算法及其扩展[finish] 数论函数和莫比 ...