Description
IT developing computer games decided to upgrade its-to-reward its employees. Now it looks the following. 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 are not divisible by any number from 2 to Ten every developer of this game Gets a small bonus.
A game designer Petya knows that's the company is just on to release a new game This was partly developed by him. On the basis's experience he predicts that n people would buy the game during the first month. Now Petya wants to determine how many times he'll get the bonus. Help him to know it.
Input
The only line of the input contains one integer n (1≤ n ≤10)-the prediction on the NUM ber of people who'll buy the game.
Output
Output One integer showing how many numbers from 1 to n is not divisible by any number from 2 to .
Examples
input
12
Output
2
Principle of tolerance and repulsion
#include <iostream> #include <algorithm> #include <cstdio>using namespace std;typedef long Long ll;int Num[20];int N; ll sum;//n is the number of elements of 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 (b);//This is the least common multiple method}ll DFS (ll lcmn,int ID) //LCMN Here is a 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