K -
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

Input
12
Output
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(容斥)的更多相关文章

  1. Codeforces.348D.Turtles(容斥 LGV定理 DP)

    题目链接 \(Description\) 给定\(n*m\)的网格,有些格子不能走.求有多少种从\((1,1)\)走到\((n,m)\)的两条不相交路径. \(n,m\leq 3000\). \(So ...

  2. codeforces 630K - Indivisibility

    K. Indivisibility 题意:给一个n(1 <= n <= 10^18)的区间,问区间中有多少个数不能被2~10这些数整除: 整除只需要看素数即可,只有2,3,5,7四个素数: ...

  3. codeforces 466C 计数 codeforces 483B 二分 容斥

    题意:给你n个数,将他们分成连续的三个部分使得每个部分的和相同,求出分法的种数. 思路:用一个数组a[i]记下从第一个点到当前i点的总和.最后一个点是总和为sum的点,只需求出总和为1/3sum的点和 ...

  4. codeforces 449D DP+容斥

    Jzzhu and Numbers Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u ...

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

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

  6. Codeforces 100548F - Color (组合数+容斥)

    题目链接:http://codeforces.com/gym/100548/attachments 有n个物品 m种颜色,要求你只用k种颜色,且相邻物品的颜色不能相同,问你有多少种方案. 从m种颜色选 ...

  7. 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 ...

  8. Codeforces 803F Coprime Subsequences (容斥)

    Link:http://codeforces.com/contest/803/problem/F 题意:给n个数字,求有多少个GCD为1的子序列. 题解:容斥!比赛时能写出来真是炒鸡开森啊! num[ ...

  9. 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 ...

  10. Codeforces Round #258 (Div. 2) 容斥+Lucas

    题目链接: http://codeforces.com/problemset/problem/451/E E. Devu and Flowers time limit per test4 second ...

随机推荐

  1. 前端开发之旅- 移动端HTML5实现文件上传

    一. 在一个客户的webapp项目中需要用到 html5调用手机摄像头,找了很多资料,大都是 js调用api  然后怎样怎样,做了几个demo测试发现根本不行, 后来恍然大悟,用html5自带的 in ...

  2. [Windows Server 2008] 查看ASP详细错误信息方法

    ★ 欢迎来到[护卫神·V课堂],网站地址:http://v.huweishen.com ★ 护卫神·V课堂是护卫神旗下专业提供服务器教学视频的网站,每周更新视频. ★ 本节我们将带领大家:查看IIS下 ...

  3. hibernate注解之@Onetomany、@Manytoone、@JoinColumn

    @Onetomany用于实体类与数据库表映射中少的一方,请看下面的例子. 假设一个用户只有一种角色,用户和角色是onetomany的关系 用户实体 @Entity @Table(name=" ...

  4. FTP工作原理

    FTP工作原理 FTP两种传输方式:1.ASCII传输2.二进制传输 FTP主被动原理: 主动方式:1.用户与服务器建立控制通道2.客户端发出PORT指令,主动告诉服务器端口号3.服务器主动通过20端 ...

  5. Makefile精髓篇【转】

    什么是makefile?或许非常多Winodws的程序猿都不知道这个东西,由于那些Windows的IDE都为你做了这个工作,但我觉得要作一个好的和professional的程序猿,makefile还是 ...

  6. R语言图表

    条形图 在R语言中创建条形图的基本语法是 barplot(H, xlab, ylab, main, names.arg, col) H是包含在条形图中使用的数值的向量或矩阵 xlab是x轴的标签 yl ...

  7. -bash:whois:command not found

    在centOS 下,如果出现-bash:whois:command not found的问题, 则yum install 安装whois软件 yum install -y jwhois 包名是jwho ...

  8. 默认ttl参考

    UNIX 及类 UNIX操作系统 ICMP 回显应答的 TTL 字段值为 255 Compaq Tru64 5.0 ICMP 回显应答的 TTL 字段值为 64 WINXP-32bit 回显应答的 T ...

  9. Linux文件、目录属性

    文件.目录属性 可能有人觉得,文件这东西这么普通有什么好讲的,,,其实不然,在linux中一切皆文件,搞清楚文件的本质,将对我们大有裨益. 文件.目录属性简介 举个例子 randolf@localho ...

  10. C写的AES(ECB/PKCS5Padding)

    摘自POLARSSL #pragma once #define AES_ENCRYPT 1 #define AES_DECRYPT 0 struct aes_context { int nr; /*! ...