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.

Examples
input
12
output
2
容斥原理
#include<iostream>
#include <algorithm>
#include<cstdio>
using namespace std;
typedef long long LL;
int num[20];
int n;
LL sum;//n是num[]的元素个数
LL m;
LL gcd(LL a,LL b)
{
if(b==0) return a;
return gcd(b,a%b);
}
LL lcm(LL a,LL b)
{
return a*b/gcd(a,b); //这是求最小公倍数的方法
}
LL dfs(LL lcmn,int id) //这里传进来的lcmn是long long !!!
{
if(id<n-1) return dfs(lcmn,id+1)-dfs(lcm(lcmn,num[id+1]),id+1);
return m/lcmn;
}
int main()
{
int t;
n=9;
cin>>m;
for(int i=0; i<n; i++)
{
num[i]=i+2;
}
sort(num,num+n);
sum=0;
for(int i=0; i<n; i++)
sum+=dfs(num[i],i);
cout<<m-sum<<endl;
return 0;
}

  

Experimental Educational Round: VolBIT Formulas Blitz K的更多相关文章

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

  2. Experimental Educational Round: VolBIT Formulas Blitz

    cf的一次数学场... 递推 C 题意:长度<=n的数只含有7或8的个数 分析:每一位都有2种可能,累加不同长度的方案数就是总方案数 组合 G 题意:将5个苹果和3个梨放进n个不同的盒子里的方案 ...

  3. Experimental Educational Round: VolBIT Formulas Blitz N

    Description The Department of economic development of IT City created a model of city development ti ...

  4. Experimental Educational Round: VolBIT Formulas Blitz J

    Description IT City company developing computer games invented a new way to reward its employees. Af ...

  5. Experimental Educational Round: VolBIT Formulas Blitz F

    Description One company of IT City decided to create a group of innovative developments consisting f ...

  6. Experimental Educational Round: VolBIT Formulas Blitz D

    Description After a probationary period in the game development company of IT City Petya was include ...

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

  8. Experimental Educational Round: VolBIT Formulas Blitz B

    Description The city administration of IT City decided to fix up a symbol of scientific and technica ...

  9. Experimental Educational Round: VolBIT Formulas Blitz A

    Description The HR manager was disappointed again. The last applicant failed the interview the same ...

随机推荐

  1. new与delete,malloc与free

    1.new_delete与malloc_free ❶malloc/free: malloc原型: void *malloc(long NumBytes) 该函数分配了NumBytes个字节,并返回了指 ...

  2. intellij idea 在执行maven的操作 install等会出现中文乱码?其他程序打印正常?

    之前一直碰到过这个问题,也没在意,因为那个中文对我来说用处不大,今天看着务必难受,一定把他给解决了,查了一下,找到了解决方法,如下: 首先打开你的设置. Setting->maven->r ...

  3. CoreData的增删改查

    首先使用CoreData创建Demo,勾上CoreData选项 然后创建Entity对象,点击Add Entity(+)按钮 生成Entity对象 重命名双击Entity选项,然后输入Person 设 ...

  4. php学习笔记-php中的比较运算符

    其中比较难懂的是==和=== ==是只比较两个变量的值,不仅仅是用于比较两个数是否相等,还可以比较int和string,不过会先转化string为int类型再比较,值相等则返回true,值不相等则返回 ...

  5. java过滤器 Fliter

    定义:过滤器是一个服务器端组件,他可以截取用户端请求信息与响应信息,并对信息进行过滤 例:当进入csdn要进行文章编辑时,检测用户是否登录,若未登录,跳转到登录界面. 过滤器操作方法: init() ...

  6. R: 自动计算代码运行时间

    ################################################### 问题:代码运行时间   18.4.25 怎么计算代码的运行时间? 解决方案: ptm = pro ...

  7. ZROI2018普转提day2t3

    传送门 分析 考试的时候sb了......我们发现可以按照先序遍历将一棵树变成一个序列,而不需要删的数的数量便是最长上升子序列的长度,但是还有一个问题就是如果在5和7之间有3个空的位置就无法填入合法的 ...

  8. Person.post请求------详细过程

    首先,在PersonRepository的父类中查找save方法,如下: @Override @TransactionalMethod public <S extends D> S sav ...

  9. Thread.currentThread().getContextClassLoader() 和 Class.getClassLoader()区别

    查了一些资料也不是太明白两个的区别,但是前者是最安全的用法 打个简单的比方,你一个WEB程序,发布到Tomcat里面运行.首先是执行Tomcat org.apache.catalina.startup ...

  10. centos中JDK版本冲突的问题

    在centos环境下,我JDK版本安装了jdk6,jdk7.系统还自带了一个JDK7. 我在查看JDK版本是,发现不是我在/etc/profile中配置的. 1:which java 查看Java的命 ...