請求支援
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
bool bigger(string s,string t){
for(int i=0;i<s.length();i++){
if(s[i]==t[i])continue;
else return s[i]<t[i];
}
}
int main(){
vector<int>d;vector<string>v;string s;
while(cin>>s){
d.clear();bool b=0;
for(int i=1;i<=s.length()/2;i++)if(s.length()%i==0)d.push_back(i);
for(int i=0;i<d.size();i++){
v.clear();
string t="";for(int j=0;j<s.length();j++){
t+=s[j];if((j+1)%d[i]==0){
v.push_back(t);t="";
}
}sort(v.begin(),v.begin()+v.size(),bigger);
t="";for(int i=0;i<v.size();i++)t+=v[i];
if(t!=s){b=1;cout<<t<<endl;}
}if(b==0)cout<<"bomb!\n";
}
}
Accept
Accept
記憶體區段錯誤! Segmentation fault (core dumped)