| ||||||||||
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 |
HELp me - WA - 1580Why my code WA? I think my input and output is right #include<cstdio> #include<algorithm> #include<string.h> using namespace std; int main() { char input[1000]; char *kt1; char *kt2; int jum[1000]; int jml,tot,cek; while(gets(input)) { jml=0; memset(jum,0,sizeof(jum)); if(strcmp(input,"-1")==0) { break; } kt1=strtok(input," "); kt2=strtok(NULL," "); printf("appx(%s,%s) = ",kt1,kt2); int c=0; for(int i=0;i<strlen(kt1);i++) { for(int j=0;j<strlen(kt2);j++) { if(kt1[i]==kt2[j]) { jum[c]++; int a=i+1; int b=j+1; while(a < strlen(kt1) && b < strlen(kt2)) { if(kt1[a]==kt2[b]) { jum[c]++; } a++; b++; } c++; } } } sort(jum,jum+c); jml=jum[c-1]; jml=jml*2; tot=strlen(kt1)+strlen(kt2); for(int k=1;k<tot;k++) { if(jml > 0) { if(jml % k == 0 && tot % k == 0) { jml=jml/k; tot=tot/k; } } } //printf("%d %d\n",jml,tot); if(jml == 0) { printf("0\n",kt1,kt2); } else if(jml==tot) { printf("1\n",kt1,kt2); } else { printf("%d/%d\n",jml,tot); } } return 0; } Please help with English... Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator