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

Re:wa了,帮帮忙指点一下..

Posted by snailly18 at 2006-07-24 08:49:52 on Problem 2895
In Reply To:wa了,帮帮忙指点一下.. Posted by:snailly18 at 2006-07-24 08:49:19
这是代码
#include<stdio.h>
#define MAX 1001
main()
{
	int time;
	scanf("%d",&time);
	while(time--)
	{
		int per,fix;
		unsigned sum=0;
		char s[MAX];
		int i=0;
		scanf("%u %u",&per,&fix);
		fflush(stdin);
		gets(s);
    	for(i=0;s[i]!='\0';i++)
		{
	    	if(s[i]==' '||s[i]=='A'||s[i]=='D'||s[i]=='G'||s[i]=='J'||s[i]=='M'||s[i]=='P'||s[i]=='T'||s[i]=='W') sum=sum+per;
			else if(s[i]=='B'||s[i]=='E'||s[i]=='H'||s[i]=='K'||s[i]=='N'||s[i]=='Q'||s[i]=='U'||s[i]=='X') sum=sum+2*per;
			else if(s[i]=='C'||s[i]=='F'||s[i]=='I'||s[i]=='L'||s[i]=='O'||s[i]=='R'||s[i]=='V'||s[i]=='Y') sum=sum+3*per;
			else if(s[i]=='S'||s[i]=='Z') sum=sum+4*per;
		}
		for(i=1;s[i]!='\0';i++)
		{
			if(s[i]>='A'&&s[i]<='C'&&s[i-1]>='A'&&s[i-1]<='C')	sum=sum+fix;
			else if(s[i]>='D'&&s[i]<='F'&&s[i-1]>='D'&&s[i-1]<='F')	sum=sum+fix;
			else if(s[i]>='G'&&s[i]<='I'&&s[i-1]>='G'&&s[i-1]<='I')	sum=sum+fix;
			else if(s[i]>='J'&&s[i]<='L'&&s[i-1]>='J'&&s[i-1]<='L')	sum=sum+fix;
			else if(s[i]>='M'&&s[i]<='O'&&s[i-1]>='M'&&s[i-1]<='O')	sum=sum+fix;
			else if(s[i]>='P'&&s[i]<='S'&&s[i-1]>='P'&&s[i-1]<='S')	sum=sum+fix;
			else if(s[i]>='T'&&s[i]<='V'&&s[i-1]>='T'&&s[i-1]<='V')	sum=sum+fix;
			else if(s[i]>='W'&&s[i]<='Z'&&s[i-1]>='W'&&s[i-1]<='Z')	sum=sum+fix;
		}
		printf("%u\n",sum);
	}
	return 1;
}

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