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 |
这题都过不了?牛人帮看一下代码吧。3x#include<stdio.h> char a[1001]; main() { unsigned t; scanf("%u",&t); while(t--) { unsigned p,w,time=0; scanf("%u%u",&p,&w); getchar(); gets(a); char *s=a; while(*s) { switch (*s) { case 'A':if((s>a)&&(*(s-1)>='A')&&(*(s-1)<='C'))time+=w;time+=p;break; case 'B':if((s>a)&&(*(s-1)>='A')&&(*(s-1)<='C'))time+=w;time+=2*p;break; case 'c':if((s>a)&&(*(s-1)>='A')&&(*(s-1)<='C'))time+=w;time+=3*p;break; case 'D':if((s>a)&&(*(s-1)>='D')&&(*(s-1)<='F'))time+=w;time+=p;break; case 'E':if((s>a)&&(*(s-1)>='D')&&(*(s-1)<='F'))time+=w;time+=2*p;break; case 'F':if((s>a)&&(*(s-1)>='D')&&(*(s-1)<='F'))time+=w;time+=3*p;break; case 'G':if((s>a)&&(*(s-1)>='G')&&(*(s-1)<='I'))time+=w;time+=p;break; case 'H':if((s>a)&&(*(s-1)>='G')&&(*(s-1)<='I'))time+=w;time+=2*p;break; case 'I':if((s>a)&&(*(s-1)>='G')&&(*(s-1)<='I'))time+=w;time+=3*p;break; case 'J':if((s>a)&&(*(s-1)>='J')&&(*(s-1)<='L'))time+=w;time+=p;break; case 'K':if((s>a)&&(*(s-1)>='J')&&(*(s-1)<='L'))time+=w;time+=2*p;break; case 'L':if((s>a)&&(*(s-1)>='J')&&(*(s-1)<='L'))time+=w;time+=3*p;break; case 'M':if((s>a)&&(*(s-1)>='M')&&(*(s-1)<='O'))time+=w;time+=p;break; case 'N':if((s>a)&&(*(s-1)>='M')&&(*(s-1)<='O'))time+=w;time+=2*p;break; case 'O':if((s>a)&&(*(s-1)>='M')&&(*(s-1)<='O'))time+=w;time+=3*p;break; case 'P':if((s>a)&&(*(s-1)>='P')&&(*(s-1)<='S'))time+=w;time+=p;break; case 'Q':if((s>a)&&(*(s-1)>='P')&&(*(s-1)<='S'))time+=w;time+=2*p;break; case 'R':if((s>a)&&(*(s-1)>='P')&&(*(s-1)<='S'))time+=w;time+=3*p;break; case 'S':if((s>a)&&(*(s-1)>='P')&&(*(s-1)<='S'))time+=w;time+=4*p;break; case 'T':if((s>a)&&(*(s-1)>='T')&&(*(s-1)<='V'))time+=w;time+=p;break; case 'U':if((s>a)&&(*(s-1)>='T')&&(*(s-1)<='V'))time+=w;time+=2*p;break; case 'V':if((s>a)&&(*(s-1)>='T')&&(*(s-1)<='V'))time+=w;time+=3*p;break; case 'W':if((s>a)&&(*(s-1)>='W')&&(*(s-1)<='Z'))time+=w;time+=p;break; case 'X':if((s>a)&&(*(s-1)>='W')&&(*(s-1)<='Z'))time+=w;time+=2*p;break; case 'Y':if((s>a)&&(*(s-1)>='W')&&(*(s-1)<='Z'))time+=w;time+=3*p;break; case 'Z':if((s>a)&&(*(s-1)>='W')&&(*(s-1)<='Z'))time+=w;time+=4*p;break; case ' ':time+=p;break; } s++; } printf("%u\n",time); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator