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 |
那位 仁兄 行个 好 ,帮 我 好好看吧!!非常感谢!一直超时!我交了20多遍了!!#include <iostream> using namespace std; int map(char x); void Quicksort(int x[],int p,int r); class Num { public: Num(){again=0;} public: int again; }; int main() { int st[100000]; Num *sm=new Num[10000000]; int n; char ch; cin>>n; int uu=0; for(int i=0;i<n;i++) { int j=0; int sum=0; do { cin>>ch; if(ch!='-') {sum=sum*10+map(ch);j++;} }while(j!=7); sm[sum].again++; if(sm[sum].again==2) {st[uu]=sum;uu++;} } Quicksort(st,0,uu-1); for(int i=0;i<uu;i++) printf("%d%d%d-%d%d%d%d %d\n", st[i]/1000000,(st[i]/100000)%10, (st[i]/10000)%10,(st[i]/1000)%10, (st[i]/100)%10,(st[i]/10)%10, st[i]%10,sm[st[i]].again); if(uu==0)cout<<"No duplicates."; return 0; } int map(char x) { if(x>='0'&&x<='9') return x-'0'; else if(x>='A'&&x<='P') return (x-'A')/3+2; else if(x>='R'&&x<='Y') return (x-'Q')/3+7; } void Quicksort(int x[],int p,int r) { if(p>=r)return ; int y=x[r]; int i=p-1; for(int j=p;j<=r-1;j++) { if(x[j]<=y) {i++;swap(x[i],x[j]);} } swap(x[i+1],x[r]); Quicksort(x,p,i); Quicksort(x,i+2,r); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator