CodeForces - 630J Divisibility (数学求最小公倍数)

CodeForces - 630J
Divisibility
Time Limit: 500MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u

Submit Status

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 the next number of sales is divisible by all numbers 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 divisible by all numbers from 2 to 10.

Sample Input

Input
3000
Output
1

Source

Experimental Educational Round: VolBIT Formulas Blitz
//题意:
给你一个n表示购买游戏软件的人数,当购买游戏软件的人数可以整除2--10,那么员工就会被奖励,问员工一共被奖励了几次。
//思路:
因为是可以整除2-10,那么表示能整除人数一定2--10的最小公倍数,所以最多被奖励的次数是n/m。m表示最小公倍数。
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define INF 0x3f3f3f3f
#define ll long long
#define N 10010
#define M 1000000007
using namespace std;
int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}
int ggcd()
{
	int n=1;
	for(int i=2;i<=10;i++)
	{
		n=n*i/gcd(n,i);
	}
	return n;
}
int main()
{
	ll n;
	int m=ggcd();
	while(scanf("%lld",&n)!=EOF)
	{
		ll ans=n/m;
		printf("%lld\n",ans);
	}
	return 0;
}

你可能感兴趣的:(CodeForces - 630J Divisibility (数学求最小公倍数))