测试点#9 WA ,各位dalao们帮帮我看看(有可能我编得太复杂了,一道橙题用66行)
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstdio>
using namespace std;
string tostring(long long y){
long long d=0,j=y;
while(j!=0){
d++;
j/=10;
}
int a[d];
for(j=0;j<d;j++){
a[j]=y%10;
y/=10;
}
int s=0,f=d-1;
for(;s<f;s++,f--){
swap(a[s],a[f]);
}
string h;
for(j=0;j<d;j++){
h+=char(a[j]+'0');
}
string o;
for(long long i=0;i<h.length();i++){
if(h[i]!=' ')o+=h[i];
}
return o;
}
int main()
{
int a,b,v;
cin>>a>>b;
string z=tostring(b);
for(v=0;z[v]==0;v++){
}
string h;
for(int n=v;n<z.length();n++){
h+=z[n];
}
int y=a,m=a,w=0;
while(y){
y/=10;
w++;
}
int s[w];
for(int i=0;i<w;i++){
s[i]=a%10;a/=10;
}
sort(s,s+w);
int i=0;
for(i=0;s[i]==0;i++){}
swap(s[0],s[i]);
string r;
for(int i=0;i<w;i++){
r+=char(s[i]+'0');
}
if(h==r){
printf("OK");
}
else{
printf("WRONG_ANSWER");
}
return 0;
}
期待收到各位 dalao 的指点,谢谢!