Files
python/C++专题课程/历年试题与资料/蓝桥杯2018年试题C++/4.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

29 lines
636 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include<bits/stdc++.h>
using namespace std;
#define Maxn 59084709587505
int a[3] = {3,5,7};
int main() {
//选择set容器,set作为一个容器是用来存储同一数据类型的数据类型,并且能从一个数据集合中取出数据,
//在set中每个元素的值都唯一,而且系统能根据元素的值自动进行排序。
set<long long int> se;
long long int lucky_num = 1;
while(1) {
if(lucky_num == Maxn)
break;
for(int i = 0; i < 3; i++) {
long long int temp = lucky_num*a[i];
if(temp <= Maxn) {
cout<<temp<<endl;
se.insert(temp);
}
}
lucky_num = *se.upper_bound(lucky_num);
}
cout<<se.size()<<endl;
return 0;
}