Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

帮帮忙

Posted by 200694068 at 2007-06-24 18:56:29 on Problem 2895
#include<iostream.h>

int main()
{
	int t,i,j,sum=0,p,w,q;
	char s[10];

	cin>>t;
	for(i=0;i<t;i++)
	{	
		cin>>p>>w;
	cin.getline(s,10);
		cin.getline(s,10);
		for(j=0;;j++)
		{
			if(s[j]=='\0')break;
			if(s[j]==' '){sum+=p;continue;}
			if(s[j]=='A'||s[j]=='B'||s[j]=='C')
			{	if(s[j]=='A')sum+=p;
				if(s[j]=='B')sum+=2*p;
				if(s[j]=='C')sum+=3*p;
				q=j+1;
				for(j=j+1;;j++)
				{
					if(s[j]=='A'){sum+=p+w;continue;}
					if(s[j]=='B'){sum+=2*p+w;continue;}
					if(s[j]=='C'){sum+=3*p+w;continue;}
					if(s[j]=='\0'){j--;break;}
					if(q==j)
					{j--;break;}
					break;
				}
			}
			if(s[j]=='D'||s[j]=='E'||s[j]=='F')
			{
				if(s[j]=='D')sum+=p;
				if(s[j]=='E')sum+=2*p;
				if(s[j]=='F')sum+=3*p;
				q=j+1;		
				for(j=j+1;;j++)
				{
					if(s[j]=='D'){sum+=p+w;continue;}
					if(s[j]=='E'){sum+=2*p+w;continue;}
					if(s[j]=='F'){sum+=3*p+w;continue;}
					if(s[j]=='\0'){j--;break;}
				if(q==j)
					{j--;break;}
					break;
				}

			}
			if(s[j]=='G'||s[j]=='H'||s[j]=='I')
			{
				if(s[j]=='G')sum+=p;
				if(s[j]=='H')sum+=2*p;
				if(s[j]=='I')sum+=3*p;
				q=j+1;
				for(j=j+1;;j++)
				{
					if(s[j]=='G'){sum+=p+w;continue;}
					if(s[j]=='H'){sum+=2*p+w;continue;}
					if(s[j]=='I'){sum+=3*p+w;continue;}
					if(s[j]=='\0'){j--;break;}
					if(q==j)
					{j--;break;}
						break;
				}

			}
			if(s[j]=='J'||s[j]=='K'||s[j]=='L')
			{
				if(s[j]=='J')sum+=p;
				if(s[j]=='K')sum+=2*p;
				if(s[j]=='L')sum+=3*p;
				q=j+1;
				for(j=j+1;;j++)
				{
					if(s[j]=='J'){sum+=p+w;continue;}
					if(s[j]=='K'){sum+=2*p+w;continue;}
					if(s[j]=='L'){sum+=3*p+w;continue;}
					if(s[j]=='\0'){j--;break;}
				if(q==j)
					{j--;break;}
					break;
				}

			}
			if(s[j]=='M'||s[j]=='N'||s[j]=='O')
			{
				if(s[j]=='M')sum+=p;
				if(s[j]=='N')sum+=2*p;
				if(s[j]=='O')sum+=3*p;
				q=j+1;
				for(j=j+1;;j++)
				{
					if(s[j]=='M'){sum+=p+w;continue;}
					if(s[j]=='N'){sum+=2*p+w;continue;}
					if(s[j]=='O'){sum+=3*p+w;continue;}
					if(s[j]=='\0'){j--;break;}
			if(q==j)
					{j--;break;}
				break;
				}

			}	
			if(s[j]=='P'||s[j]=='Q'||s[j]=='R'||s[j]=='S')
			{
				if(s[j]=='P')sum+=p;
				if(s[j]=='Q')sum+=2*p;
				if(s[j]=='R')sum+=3*p;
				if(s[j]=='S')sum+=4*p;
				q=j+1;
				for(j=j+1;;j++)
				{
					if(s[j]=='P'){sum+=p+w;continue;}
					if(s[j]=='Q'){sum+=2*p+w;continue;}
					if(s[j]=='R'){sum+=3*p+w;continue;}
					if(s[j]=='S'){sum+=4*p+w;continue;}
					if(s[j]=='\0'){j--;break;}
				if(q==j)
					{j--;break;}
					break;
				}

			}
			if(s[j]=='T'||s[j]=='U'||s[j]=='V')
			{
				if(s[j]=='T')sum+=p;
				if(s[j]=='U')sum+=2*p;
				if(s[j]=='V')sum+=3*p;
				q=j+1;
				for(j=j+1;;j++)
				{
					if(s[j]=='T'){sum+=p+w;continue;}
					if(s[j]=='U'){sum+=2*p+w;continue;}
					if(s[j]=='V'){sum+=3*p+w;continue;}
					if(s[j]=='\0'){j--;break;}
				if(q==j)
					{j--;break;}
					break;
				}

			}
			if(s[j]=='W'||s[j]=='X'||s[j]=='Y'||s[j]=='Z')
			{
				if(s[j]=='W')sum+=p;
				if(s[j]=='X')sum+=2*p;
				if(s[j]=='Y')sum+=3*p;
				if(s[j]=='Z')sum+=4*p;
				q=j+1;
				for(j=j+1;;j++)
				{
					if(s[j]=='W'){sum+=p+w;continue;}
					if(s[j]=='X'){sum+=2*p+w;continue;}
					if(s[j]=='Y'){sum+=3*p+w;continue;}
					if(s[j]=='Z'){sum+=4*p+w;continue;}
					if(s[j]=='\0'){j--;break;}
			if(q==j)
					{j--;break;}
				break;
				}

			}
			
			




		}
		cout<<sum<<endl;
			sum=0;

	}
	return 0;
}		




Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator