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. python爬虫实战(3)--图片下载器

    本篇目标 1.输入关键字能够根据关键字爬取百度图片 2.能够将图片保存到本地文件夹 1.URL的格式 进入百度图片搜索apple,这时显示的是瀑布流版本,我们选择传统翻页版本进行爬取.可以看到网址为: ...

  2. Codeforces 464E The Classic Problem (最短路 + 主席树 + hash)

    题意及思路 这个题加深了我对主席树的理解,是个好题.每次更新某个点的距离时,是以之前对这个点的插入操作形成的线段树为基础,在O(logn)的时间中造出了一颗新的线段树,相比直接创建n颗线段树更省时间. ...

  3. WCF客户端调用并行最大同时只支持两个请求

    做项目的时候发现 频繁调用WCF服务时 明明一次性发起了几十个请求 而在服务端记录的日志却显示出现了排队的迹象 并且都是最大并发数为2 在网上狂搜 大家给出来的解决方法都是增加web.config里面 ...

  4. C++面向对象类的实例题目四

    题目描述: 以面向对象的概念设计一个类,此类包含3个私有数据:unlead.lead(无铅汽油和有铅汽油)以及total(当天总收入,无铅汽油的价格是17元/升,有铅汽油的加个是16元/升),请以构造 ...

  5. Java线程池拒绝策略

    Java线程池拒绝策略 相关资料: 线程池的RejectedExecutionHandler(拒绝策略):http://blog.csdn.net/jgteng/article/details/544 ...

  6. Luogu 3168 [CQOI2015]任务查询系统

    区间修改单点查询,又观察到是一个k小,考虑主席树上做差分 一开始样例疯狂挂,后来发现主席树在一个历史版本上只能修改一次,所以要开2*n个根结点,记录一下每个时间对应的根结点编号 然后80分,考虑到当一 ...

  7. java反射中,Class.forName和classloader的区别

    http://blog.csdn.net/qq_27093465/article/details/52262340

  8. Android之悬浮窗口实现(WindowManager)

    工作中遇到一些项目需要把窗体显示在最上层,像来电弹窗显示电话号码等信息.拦截短信信息显示给用户或者游戏中实现声音的调节,我们想这些数据放在最上层,activity就满足不了我们的需求了,有些开发者使用 ...

  9. C# 链表 --增 -删-反转-删除最小值

    1. Node.cs namespace 链表 { public class Node<T> { public T Data; //这个就是地址 public Node<T> ...

  10. [Algorithm]树与二叉树

    一.树与二叉树相关算法 1.二叉树按顺序结构存储,求编号为i和j的两个结点的最近公共祖先结点的值 1 ElemType CommonAncestor( SeqTree T, int i, int j ...