文章

6

粉丝

228

获赞

0

访问

28.1k

头像
全排列
P1736 华东师范大学2020年机试题
发布于2022年4月7日 15:28
阅读数 4.7k

#include <bits/stdc++.h>
using namespace std;

bool check(string s){
    int num = atoi(s.c_str());
    if(num%30==0) return true;
    return false;
}

int main(){
    string s;
    cin>>s;
    int maxx=0;
    do{
        if(check(s)){
            maxx = max(maxx,atoi(s.c_str()));
        }
    }while(next_permutation(s.begin(),s.end()));
    cout<<(maxx==0?-1:maxx)<<endl;

    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发