蒟蒻65求助,大佬们帮忙看一看!
查看原帖
蒟蒻65求助,大佬们帮忙看一看!
609307
yizongyuan楼主2022/2/8 09:31
//#include<bits/stdc++.h>
//#include<windows.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
bool cmp(char a,char b){
	return a>b;
}
int main(){
	char str[10001]={};
	cin>>str;
	bool f=false;
	int n=0;
	for(int i=0;i<strlen(str);i++){
		if(str[i]=='0') f=true;
		n+=str[i]-'0';
	}if(n%3==0 && f){
		sort(str,str+strlen(str),cmp);
		cout<<str;
	}else{
		cout<<-1;
	}
	return 0;
}
2022/2/8 09:31
加载中...