tips:我们需要注意的是我们用ll定义的数据,int是不能用ll的数据的,定义必须保持一致
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#define ll long long
using namespace std;
map<ll,int>mp;
ll ans = 0;
int main()
{
priority_queue<ll,vector<ll>,greater<ll> >q;
q.push(3),q.push(5),q.push(7);
ll cnt = 0;
while(q.size())
{
ll t = q.top(); //特别注意这里,ll的数据不能用int定义
q.pop();
cnt++;
if(t==59084709587505)
{
cout<<cnt<<endl;
return 0;
}
if(!mp[t*3])
{
q.push(t*3);
mp[t*3] = 1;
}
if(!mp[t*5])
{
q.push(t*5);
mp[t*5] = 1;
}
if(!mp[t*7])
{
q.push(t*7);
mp[t*7] = 1;
}
}
return 0;
}
要加油啊!!!