文章
55
粉丝
100
获赞
12
访问
33.1k
#include <iostream>
#include <vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
string str;
cin>>str;
int n = str.length();
vector<char> v(n);
for(int i = 0; i<n; i++){
v[i] = str[i];
}
vector<int> shuzi;
int s = 0;
sort(v.begin(),v.end());
do{
string str = "";
for(int i =0; i<n; i++){
str+=v[i];
}
int res = stoi(str);
if(res % 30 == 0){
shuzi.push_back(res);
}
}while(next_permutation(v.begin(),v.end()));
int max = shuzi.empty() ? -1 : shuzi.front();
for(vector<int>::iterator it = shuzi.begin(); it!=shuzi.end(); it++){
if(*it > max){
max = *it;
}
}
cout<<max<<endl;
}
登录后发布评论
暂无评论,来抢沙发