codeforces 630J Divisibility
2016-02-19 20:30
239 查看
J. Divisibility
time limit per test
0.5 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output
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.
Examples
input
output
time limit per test
0.5 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output
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.
Examples
input
3000
output
1 题意:给你一个长整形数n,让你计算出1到n中有多少个数可以被2到10之间的所有数整除,包括2和10; 题解:先打表找规律,发现任意两个相邻的满足条件的两个数之间相差 2520,所以拿n除以2520就是结果
#include<stdio.h> //j #include<string.h> #include<stdlib.h> #include<algorithm> #include<math.h> #include<queue> #include<stack> #define INF 0x3f3f3f #define MAX 100100 #define LL long long using namespace std; int main() { LL n,m,j,i; LL sum; while(scanf("%lld",&n)!=EOF) { sum=n/2520; printf("%lld\n",sum); // sum=0; //打表找规律 // for(i=1;i<=n;i++) // { // int flag=1; // for(j=6;j<=10;j++) // { // if(i%j!=0) // { // flag=0; // break; // } // } // if(flag) // { // printf("%d ",i); // sum++; // } // } // printf("\n%d\n",sum); } return 0; }
相关文章推荐
- HDU 4908 BestCoder Sequence
- 【lighting】Color and Vision
- 在顶点照明模式下如何取得光源信息
- kmp习题大全
- 使用apt-get下载oracle-java-8代码
- ActiveMQ平台搭建 python推送接收
- jQuery自学教程(三)——DOM操作
- Eclipse 配置SSH 详解
- iOS-证书配置
- git submodules
- 霍夫变换检测直线--原理和Matlab实现
- android-APP长期运行于后台,重启后如何避免异常
- 字符串的全排列和组合算法
- 两个Fragment之间传递数据之一
- 整理摘抄 宏定义笔记
- PHP需要掌握的一些工具
- 16-02-19 Your content must have a ListView whose id attribute is 'android.R.id.list'
- Netty学习(一)
- HTML DOM appendChild()方法
- Android多线程断点续传下载