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 |
Re:赞啊,附上代码In Reply To:赞啊,附上代码 Posted by:15310320305 at 2016-05-06 13:39:27 > > 我之前是字符数组开小了,总WA,,看了你这个后我也加到了300,AC了!!! > 借鉴了其它大神的思路 > > > #include<algorithm> > #include<stdio.h> > #include<string.h> > using namespace std; > int n=0; > int m=0; > int stream(int n){ > int s = 1000000; > for(int i=0;i<m;i++) > s=s/10; > m++; > return s*n; > } > int str[100005]; > int main(){ > int t; > scanf("%d",&t); > getchar(); > while(t--) > { > > m=0; > char s[300]; > int ss=0; > gets(s); > for(int i=0;i<strlen(s);i++) > { > if(s[i]>='0'&&s[i]<='9'){int h = s[i]-'0';ss+=stream(h);} > else if(s[i]=='A'||s[i]=='B'||s[i]=='C')ss+=stream(2); > else if(s[i]=='D'||s[i]=='E'||s[i]=='F')ss+=stream(3); > else if(s[i]=='G'||s[i]=='H'||s[i]=='I')ss+=stream(4); > else if(s[i]=='J'||s[i]=='K'||s[i]=='L')ss+=stream(5); > else if(s[i]=='M'||s[i]=='N'||s[i]=='O')ss+=stream(6); > else if(s[i]=='P'||s[i]=='R'||s[i]=='S')ss+=stream(7); > else if(s[i]=='T'||s[i]=='U'||s[i]=='V')ss+=stream(8); > else if(s[i]=='W'||s[i]=='X'||s[i]=='Y')ss+=stream(9); > } > str[n++]= ss; > } > sort(str,str+n); > int num=1; > int flag=0; > for(int i=0;i<n-1;i++){ > while(str[i]==str[i+1]){ > num++; > i++; > flag=1; > } > if(num>1){ > printf("%0.3d-%0.4d %d\n",str[i]/10000,str[i]%10000,num); > num=1; > } > } > if(flag==0)printf("No duplicates.\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