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!!!!!!!!搞不懂怎莫错了,大牛给看看阿。。。。#include <stdio.h> #include<string.h> int main() { int t,p,w,seat,i,k; long time1=0,time2=0,time; char a[2000]; scanf("%d",&t); while(t--) { scanf("%d%d",&p,&w); getchar(); gets(a); k=strlen(a)-1; for(i=0;i<=k;i++) { if(a[i]!=' ') { if(a[i]<='O') { seat=(a[i]-65)%3+1; //从A到O time1+=seat*p; //按键的时间 if((a[i+1]-65)/3==(a[i]-65)/3) //若在一起 等待的时间 time2+=w; } if(a[i]<='S'&&a[i]>='P') //有四个键 { seat=a[i]-'P'+1; time1+=seat*p; if((a[i]-'P')/4==(a[i+1]-'P')/4) time2+=w; } if(a[i]<='V'&&a[i]>='T') { seat=a[i]-'T'+1; time1+=seat*p; if((a[i]-'T')/3==(a[i+1]-'T')/3) time2+=w; } if(a[i]<='Z'&&a[i]>='W') { seat=a[i]-'w'+1; time1+=seat*p; if((a[i]-'W')/4==(a[i+1]-'W')/4) time2+=w; } } else time1+=p; } time=time1+time2; printf("%d\n",time); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator