[SDUT] 2019SDUTACM first road trials pursuit of F- X

Problem Description

X in everyone's help finally found a sister paper, began the pursuit of the long road, so we guess X can catch on it?

X initial heart has a value of sister paper, paper for sister X has a good impression value, a series of events occur in the pursuit, when X cardiac sister paper of value is not less than 100 , and sister paper of X goodwill value it is not less than 100 when, X- caught up sister paper. After the two values and will not be less than 100 cases of broke up.

Event 1 : dinner with two people, then the heart value and goodwill values have increased 5

Event 2 : shopping together two people, then the heart value and goodwill values have increased 10

Event 3 : If X bought a gift for sister paper, the value decreases cardiac 5 , increase the value of goodwill 10

Event 4 : If the sister paper to X to buy a gift, then the value increases heart 20 , reducing the value of goodwill 5

So we guess it.

Input

 

The first line of the input n ( n <100 ), indicates that a n events.

After the n lines of a character from an event that i happened. (Event 1 designations A , event 2 code of B, event 3 code of C , event 4 designations D )

The last line, the input two integers K1, k2 (0 <K1 <0 && 100 <K2 <100) , K1 represents X to the value of the cardiac sister paper, K2 represents a sister paper of X goodwill value.

Output

 

Output line.

If X catch up with my sister, then the output "happy!".

Otherwise, output "tiantai!" ( Without the quotes .

Sample Input

4
A
B
C
D
80 80

Sample Output

happy!


 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <string.h>
 4 
 5 int main()
 6 {
 7     int i,n,m,z,f=0;
 8     char a[100];
 9     scanf("%d",&z);
10     getchar();
11     for(i=0;i<z;i++)
12     {
13         scanf("%c",&a[i]);
14         getchar();
15     }
16     scanf("%d %d",&n,&m);
17     for(i=0;i<z;i++)
18     {
19         if(a[i]=='A')
20         {
21             n=n+5;
22             m=m+5;
23         }
24         else if(a[i]=='B')
25         {
26             n=n+10;
27             m=m+10;
28         }
29         else if(a[i]=='C')
30         {
31             n=n-5;
32             m=m+10;
33         }
34         else if(a[i]=='D')
35         {
36             n=n+20;
37             m=m-5;
38         }
39         printf("%d %d\n",n,m);
40         if(n>=100&&m>=100)
41         {
42              f=1;
43 
44         }
45 
46     }
47     if(f==0)
48     {
49          printf("tiantai!\n");
50     }
51     else printf("happy!\n");
52     return 0;
53 }

 

Very simple one subject, only need to pay attention to avoid the influence of a carriage return character input each time when you finish a job once the judge can 

issue lies in the process and my classmates discussed, found his character input code is such :
1     scanf("%d",&z);
2     getchar();
3     for(i=0;i<z;i++)
4     {
5         scanf("%s",&a[i]);
6     }
 

Here for entering characters, he used the% s, but do not need to consider the impact of a carriage return, which seems very strange;
In fact, since a character array is behind, when% s, will & a [i] headed address entered a string "X \ 0" (X capital letters), while the next input, a [i + 1 stored] at '\ 0' will be the first character of a string covering the lower, no effect in this question in.
 
 
An array of characters defined in this program is large enough, it will not affect the other, when the array size is defined as the critical value, this input method will produce could collapse due to cross-border, and when the latter variable is a when the character, the compiler will not complain (CodeBlocks).

 

 
 

Guess you like

Origin www.cnblogs.com/sdtuzxr/p/11980491.html