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. SQL server 2008安装教程

    下载SQL server 2008 r2(网上资源很多,这里给出一个:安装) 解压后右键以管理员权限打开set-up 这里可能会出现问题:.net framework 3.5未安装,可以参考 快速安装 ...

  2. 玩转Jquery

    一 jquery简介 1 jquery是什么 jQuery由美国人John Resig创建,至今已吸引了来自世界各地的众多 javascript高手加入其team. jQuery是继prototype ...

  3. php的变量引用详解

    <?php class SimpleClass { // property declaration public $var = 'a default value'; // method decl ...

  4. 71-n皇后

    N皇后问题 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  5. Spring 第一天课程

    一. 面试题部分 1. 什么是IOC?什么是DI?他们有什么区别? 答案: IOC,即控制反转.是指将原来程序中自己创建实现类对象的控制权反转到IOC容器中. IOC的别名:依赖注入(DI),DI 是 ...

  6. 914D Bash and a Tough Math Puzzle

    传送门 分析 用线段树维护区间gcd,每次查询找到第一个不是x倍数的点,如果这之后还有gcd不能被x整除的区间则这个区间不合法 代码 #include<iostream> #include ...

  7. 利用HTML5 与CSS3 做的放大镜

    利用HTML5 与CSS3 做的放大镜 html结构 <div class="wrap"> <div class="move"> < ...

  8. 修改tomcat默认的编码方式

    tomcat8以后默认编码格式是utf-8:7之前的都是iso8859-1 如果默认情况下,tomcat使用的的编码方式:iso8859-1 修改tomcat下的conf/server.xml文件 找 ...

  9. 国内物联网平台(7):Ablecloud物联网自助开发和大数据云平台

    国内物联网平台(7)——Ablecloud物联网自助开发和大数据云平台 马智 平台定位 面向IoT硬件厂商,提供设备联网与管理.远程查看控制.定制化云端功能开发.海量硬件数据存储与分析等基础设施,加速 ...

  10. C#多线程 线程嵌套调用问题

    线程嵌套指的是:线程A的执行代码启动了线程B,线程B的执行代码又启动了线程C. 我原本以为线程A被Abort后,线程B会自动被Abort,但是我大错特错了. 在这种场景下,线程的管理就非常重要了. 线 ...