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

题意:给你一个数n,找出1~n范围内不被2~10整除的数的个数。

思路:这题可以用容斥原理,找到2~10里的4个素数2,3,5,7,然后用容斥原理就行了。

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
#define inf 99999999
#define pi acos(-1.0)
int main()
{
ll n,ans;
while(scanf("%I64d",&n)!=EOF)
{
ans=n-(n/2+n/3+n/5+n/7-n/6-n/10-n/14-n/15-n/21-n/35+n/30+n/42+n/70+n/105-n/210 );
printf("%I64d\n",ans);
}
return 0 ;
}

codeforces 630K Indivisibility (容斥原理)的更多相关文章

  1. codeforces 630K - Indivisibility

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

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

  3. codeforces 630KIndivisibility(容斥原理)

    K. Indivisibility time limit per test 0.5 seconds memory limit per test 64 megabytes input standard ...

  4. Codeforces 803F(容斥原理)

    题意: 给n个正整数,求有多少个GCD为1的子序列.答案对1e9+7取模. 1<=n<=1e5,数字ai满足1<=ai<=1e5 分析: 设f(x)表示以x为公约数的子序列个数 ...

  5. hdu4135-Co-prime & Codeforces 547C Mike and Foam (容斥原理)

    hdu4135 求[L,R]范围内与N互质的数的个数. 分别求[1,L]和[1,R]和n互质的个数,求差. 利用容斥原理求解. 二进制枚举每一种质数的组合,奇加偶减. #include <bit ...

  6. Codeforces 451E Devu and Flowers(容斥原理)

    题目链接:Codeforces 451E Devu and Flowers 题目大意:有n个花坛.要选s支花,每一个花坛有f[i]支花.同一个花坛的花颜色同样,不同花坛的花颜色不同,问说能够有多少种组 ...

  7. Codeforces Round #345 (Div. 2)【A.模拟,B,暴力,C,STL,容斥原理】

    A. Joysticks time limit per test:1 second memory limit per test:256 megabytes input:standard input o ...

  8. Codeforces Round #198 (Div. 2) E. Iahub and Permutations —— 容斥原理

    题目链接:http://codeforces.com/contest/340/problem/E E. Iahub and Permutations time limit per test 1 sec ...

  9. Codeforces 839D Winter is here - 暴力 - 容斥原理

    Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n s ...

随机推荐

  1. HTTP基础知识点小结

    什么是http协议? http,超文本传输协议是现在互联网应用最为广泛的协议,所有的www文件都必须遵循这个标准设计这个最初的目的是为了发布和接收HTML文件.http就是web通信的基础,就是为了能 ...

  2. web网上书店总结(jsp+servlet)

    web网上书店总结 前端的首页.效果如下: 基本上按照页面有的内容对其实现功能.按照用户划分功能模块,有后台管理员和普通用户,登录的时候会判断账户的类别,例如0权限代表普通用户登录,1权限代表管理员登 ...

  3. 你不知道的Linux目录

    Linux二级目录及其对应的作用 主要文件

  4. Flink源码剖析:Jar包任务提交流程

    Flink基于用户程序生成JobGraph,提交到集群进行分布式部署运行.本篇从源码角度讲解一下Flink Jar包是如何被提交到集群的.(本文源码基于Flink 1.11.3) 1 Flink ru ...

  5. ctfhub技能树—sql注入—字符型注入

    打开靶机 查看页面信息 查询回显位 查询数据库名(查询所有数据库名:select group_concat(schema_name) from information_schema.schemata) ...

  6. 【易筋经】Llinux服务器初始化及常用命令大全

    Llinux服务器初始化及常用命令大全 1.关闭防火墙以及内核安全机制 systemctl stop firewalld systemctl disable firewalld ##永久性关闭 set ...

  7. 5V-12V输入输出的限流芯片,可调限至4.8A

    可是在输出电压模式:3.6V,5V,12V 在输出3.6V模式:输入电压范围2.5V-4.5V,输入关闭电压5V,限流最大4.8A 在输出5V模式,输入电压范围3.8V-6V,输输入过电压关闭6V,限 ...

  8. 如何安装快速 Docker 和 Docker-Compose 服务

    最近由于个人在大家基于 Docker  的.企业级的CI/CD 环境,所以要安装 Docker 和 Docker-Compose ,这也算是一个学习过程,就把整个过程记录下来,便于以后查询. 测试环境 ...

  9. uni-app 微信小程序 picker 三级联动

    之前做过一个picker的三级联动功能,这里分享代码给大家 具体代码: // An highlighted block <template> <view> <picker ...

  10. uni-app开发经验分享五: 解决三端页面兼容问题的方法

    在做uni-app开发的过程中,我们最头疼可能不是开发的过程中的逻辑,而是最后要做的三端兼容测试和修改,在我开发的项目中,这一步都是最头疼和令人头秃的过程,这里总结一些个人开发遇到的问题,希望对大家有 ...