Skip to content

Instantly share code, notes, and snippets.

@pinglunliao
Last active November 5, 2019 08:49
Show Gist options
  • Save pinglunliao/4c45c5ebf6f38177b24b to your computer and use it in GitHub Desktop.
Save pinglunliao/4c45c5ebf6f38177b24b to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <cstring>
int main(void)
{
int cnt;
char data[512] = "";
scanf("%d", &cnt);
while(cnt--)
{
int x, y, z, w, n, m, toxicCnt = 0;
scanf("%d %d %d %d %d %d", &x, &y, &z, &w, &n, &m);
//printf("%d %d %d %d %d %d\n", x, y, z, w, n, m);
getchar();
gets(data);
int len = strlen(data);
//printf("Len:%d %s\n", len, data);
for(int i = 0; i < len; i++)
{
//printf("toxicCnt = %d\n", toxicCnt);
if( data[i] == ' ')
continue;
m = m - n * toxicCnt;
//printf("m = %d\n", m);
if(m <= 0)
{
printf("bye~Rabbit\n");
break;
}
switch(data[i])
{
case '1':
m += x;
break;
case '2':
m += y;
break;
case '3':
m -= z;
break;
case '4':
m -= w;
toxicCnt++;
break;
}
//printf("m = %d\n", m);
if(m <= 0)
{
printf("bye~Rabbit\n");
break;
}
}
if( m > 0)
printf("%dg\n", m);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment