a271.
彩色蘿蔔
--
兔子
| From: [59.120.127.151] |
發表日期
:
2012-10-31 10:07
#include <stdio.h>
#include <stdlib.h>
int main()
{
long long count,a,i,j,red,white,yellow,mildew,poison,toxic,weight;
char array[100000],array1[100000];
int p;
while(~scanf("%d",&a))
{
for(j=0;j<a;j++)
{
p=0;
count=0;
toxic=0;
scanf("%lld %lld %lld %lld %lld %lld",&red,&white,&yellow,&mildew,&poison,&weight);
gets(array);
if(array[0]=='\0')
gets(array);
if(array[0]=='\n')
break;
for(i=0;i<100000;i++)
{
if(array[i]=='\0')
break;
if(array[i]==32)
continue;
array1[count]=array[i];
count++;
}
for(i=0;i<100000;i++)
{
if(array1[i]=='\0')
break;
array1[i]-=48;
}
array1[i]=5;
for(i=0;i<100000;i++)
{
if(array1[i]==5)
break;
if(p==1)
weight-=toxic;
if(weight<=0)
break;
if(array1[i]==1)
weight+=red;
else if(array1[i]==2)
weight+=white;
else if(array1[i]==3)
weight-=yellow;
else if(array1[i]==4)
{
p=1;
weight-=mildew;
toxic+=poison;
}
}
if(weight<=0)
printf("bye~Rabbit\n");
else
printf("%lldg\n",weight);
}
}
return 0;
}