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 |
还是WA 谁能指点一下In Reply To:为什么会WA hawk加了什么数据 还是写题风格或是编译器差别? Posted by:zzningxp at 2005-09-11 18:13:12 #include <stdio.h> #include <string.h> int main() { char st[40]; int i,j,k,m,r,d,ln,t,a[40]={0}; while (scanf("%s",st) && st[0]!='.') { ln=strlen(st)-1; for (d=-1,i=0;i<=ln;i++) { if (st[i]=='.') d=i; if (d==-1) a[i]=st[i]-'0'; else if (st[i]!='.') a[i-1]=st[i]-'0'; } a[ln]=0; for (i=ln-1;i>=0;i--) if ((a[i]==2 || a[i]==6) && (a[i]+3<a[i+1] || a[i]>=a[i+1])) { a[i]+=3; for (j=i+1;j<ln;j++) if (a[j]==5 || a[j]==9) a[j]-=3; for (j=i+1;j<ln;j++) for (k=j+1;k<ln;k++) if (a[j]>a[k]) { t=a[j]; a[j]=a[k]; a[k]=t; } break; } else if (a[i]<a[i+1]) { m=20; r=i; k=0; for (j=ln-1;j>i;j--) { if (a[j]>a[i]) if (a[j]-a[i]<m) { m=a[j]-a[i]; r=j; } if ((a[j]==5 || a[j]==9) && a[j]-3>a[i]) if (a[j]-3-a[i]<m) { m=a[j]-3-a[i]; r=j; k=1; } } if (k) a[r]-=3; t=a[i]; a[i]=a[r]; a[r]=t; for (j=i+1;j<ln;j++) if (a[j]==5 || a[j]==9) a[j]-=3; for (j=i+1;j<ln;j++) for (k=j+1;k<ln;k++) if (a[j]>a[k]) { t=a[j]; a[j]=a[k]; a[k]=t; } break; } if (i<0) printf("The price cannot be raised."); else for (i=0;i<ln;i++) { if (i==d) printf("."); printf("%d",a[i]); } printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator