#include<iostream>
using namespace std;
int main() {
int n;
cin>>n;//容斥定理
cout<<n/2+n/3+n/5+n/30-n/6-n/15-n/10+1<<endl;
return 0;
}
#include<iostream>
using namespace std;
int main() {
int n;
cin>>n;//容斥定理
cout<<n/2+n/3+n/5+n/30-n/6-n/15-n/10+1<<endl;
return 0;
}
上一篇:1036 跟奥巴马一起编程
下一篇:1059 C语言竞赛
1087 有多少不同的值(JAVA)
1087 有多少不同的值 (20 point(s))输入样例:2017...
题目当自然数 n 依次取 1、2、3、……、N 时,算式 ⌊n/2⌋+⌊n/3⌋+⌊n/5⌋ 有多少个不同的值?(注:⌊x⌋ 为取整函数,表示不超过 x 的最大自然数,即 x 的整数部分。)输入格式:输入给出一个正整数 N(2≤N≤104)N(2≤N≤10^4)N(2≤N≤104)。输出格式:在一行中输出题面中算式取到的不同值的个数。输入样例:2017输出样例:1480思路分析:把i/2 + i/3 + i/n的值插入到set中,输出set的size就是算式中不同值的个数
写在前面题目相对简单,5分钟a题floor下取整函数(不用),ceil上取整函数注意整型数组定义的大小测试用
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M