Experimental Educational Round: VolBIT Formulas Blitz K

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;
}

  

时间: 2024-07-30 10:17:23

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

Experimental Educational Round: VolBIT Formulas Blitz D

Description After a probationary period in the game development company of IT City Petya was included in a group of the programmers that develops a new turn-based strategy game resembling the well known "Heroes of Might & Magic". A part of t

Experimental Educational Round: VolBIT Formulas Blitz J

Description IT City company developing computer games invented a new way to reward its employees. 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

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 lucky numbers. Lucky number is a number that consists of digits 7 and 8 only. Find the maximum number of offices in the new building of the Tax Office g

Experimental Educational Round: VolBIT Formulas Blitz F

Description One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate e

【Codeforces Round 1132】Educational Round 61

Codeforces Round 1132 这场比赛做了\(A\).\(B\).\(C\).\(F\)四题,排名\(89\). \(A\)题\(wa\)了一次,少考虑了一种情况 \(D\)题最后做出来,但被\(hack\)了...被\(hack\)的原因是没有想到答案会超过\(10^{12}\)(毕竟这个时间上的优化也是在最后迫不得已的情况下加的,就没有考虑正确性... Codeforces 1132 C 题意:给一些区间\([l_i,r_i]\),从中删掉两个,求剩下的区间最多能够覆盖的格子数

【Codeforces】Educational Round 61

今天刚打完一场,心情异常烂,只做出来一道题,开错题了然后没钻出来,机房的小伙伴都切了四道题了...可能又要掉了,要继续努力了. 这次Edu Round比赛是这周第二次在宿舍请假了,等网安结束了就退宿吧. 比较顺利的做出了ABC,然后看人数去推了F题,不过没什么结果. 然后在改代码的时候结识了白学长,:) 话说这几天好燥啊,G题其实代码挺好理解但愣是拖了两天啊. Problem A. Regular Bracket Sequence 题目大意:现在给出 4 种括号依次为 "((" , &

Codeforces Educational Round 23

A emmmmmmmmm B emmmmmmmmm C(套路) 题意: 给定n和s(n,s<=1e18),计算n以内有多少个数x满足(x-x的各个位置数字之和)>=s 分析: 容易想到如果x相对于s很大很大,那么肯定是满足条件的 那些小于s的数,肯定是不行的 于是x就可以从s开始,往后枚举1e6个,去判定这1e6个有多少个是满足条件的,再往后的那些x肯定是满足的,直接算出多少个就行了 D(插板法) 题意: 给定一个长度为n(n<=1e6)的数列,对于这个数列的一个连续的子列,定义valu

Educational Round 15

A题Maximum Increase 大水题.最长连续递增子序列有多长. 1 #include <cstdio> 2 #include <algorithm> 3 using namespace std; 4 int main() 5 { 6 int n, a, rec = 0, len = 0, ans = 1; 7 scanf("%d",&n); 8 for(int i = 0; i < n; i++) 9 { 10 scanf("%

Educational Round 66 题解

作为橙名来水了一发…… 这次题目就比上次良心多了.7题有5题会做. 然而风格仍然很怪异……还是练少了? A 水题.不过一开始没注意细节挂了几发,罚时罚的真痛…… 明显是能除以 $k$ 就除以 $k$,否则就 $-1$.但注意不能直接最裸的模拟. 时间复杂度 $O(T\log n)$. #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> PII; const