//滴滴丑数 #include<iostream> #include<vector> using namespace std; int main(){ int n; cin>>n; if(n<=0){ return 0; } vector<int>values; values.push_back(1); int a = 0,b = 0,c = 0; while(values.size()<n){ int temp1 = values[a]*2; int temp2 = values[b]*3; int temp3 = values[c]*5; int mi = min(temp1,min(temp2,temp3)); values.push_back(mi); if(mi == temp1){ a++; } if(mi == temp2){ b++; } if(mi == temp3){ c++; } } cout<<values[values.size()-1]; return 0; }
点赞 评论

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务