Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
你何必这么麻烦写程序?直接输出答案,肯定AC!你不一直这样做么?In Reply To:Hawk,帮忙看看是哪出问题了? Posted by:wanpi0user at 2005-11-28 13:16:27 > 我已经用测试数据检测过,完全正确。但是。。。WA!! > 请看一下,是哪个CASE过不去!? > 谢谢。 > //899966 wanpi0user 2718 Wrong Answer C++ > #include <iostream.h> > int i=0; > int main() > { > int ci,cj,i1,i2,difmin,ck,sub1,sub2,length; > int group; > cin>>group; > cin.get(); > while(group--) > { > int answer=0; > int num[11]; > length=0; > char* word=new char [30]; > cin.getline(word,21); > for(int j=0;j<21;j++) > { > int a=(int)word[j]; > if(word[j]!=' '&&a>47) > { > num[length]=(int)word[j]-48; > length++; > } > } > ///////////////// > //for(int it=0;it<length;it++) cout<<num[it]<<endl; > if(length==1) {cout<<num[0]<<endl;continue;} > if(length==2) {cout<<num[1]-num[0]<<endl;continue;} > cj=length>>1;difmin=10000; > if(length%2){ > for(ck=num[0]?0:1;ck<length-1;ck++){ > sub1=num[ck];sub2=0; > for(ci=0,i1=0,i2=length-1;ci<cj;ci++){ > if(i1==ck) i1++; > if(i2==ck) i2--; > sub1*=10;sub1+=num[i1++]; > sub2*=10;sub2+=num[i2--]; > } > if(sub1-sub2<difmin) difmin=sub1-sub2; > } > } > else{ > for(ck=num[0]?1:2;ck<length;ck++){ > sub1=num[ck];sub2=num[ck-1]; > for(ci=1,i1=0,i2=length-1;ci<cj;ci++){ > while((i1==ck-1)||(i1==ck)) i1++; > while((i2==ck)||(i2==ck-1)) i2--; > sub1*=10;sub1+=num[i1++]; > sub2*=10;sub2+=num[i2--]; > } > if(sub1-sub2<difmin) difmin=sub1-sub2; > } > } > cout<<difmin<<endl; > delete[] word; > } > > return 0; > } > Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator