企业服务网站制作,免费的ppt网站,wordpress旅行地图主题,前端开发线下培训班很简单的一道题#xff0c;但是我竟然蠢到想不明白为什么如果从头生成会出现大量重复的数字。 写的时候主要出现的错误在爆int上#xff0c;一定要注意数据范围。
#include iostream
#include queue
#include setusing namespace std;
using ll lo…很简单的一道题但是我竟然蠢到想不明白为什么如果从头生成会出现大量重复的数字。 写的时候主要出现的错误在爆int上一定要注意数据范围。
#include iostream
#include queue
#include setusing namespace std;
using ll long long;int main() {ios::sync_with_stdio(false);priority_queuell, vectorll, greaterll pq;setll s;pq.push(1);s.insert(1);auto deal [](ll x) - void {if (s.count(x)) return;s.insert(x);pq.push(x);};ll x;for (int i 1; ; i) {x pq.top();pq.pop();if (i 1500) {cout The 1500th ugly number is x .\n;break;}deal(x * 2);deal(x * 3);deal(x * 5);}return 0;
}