Skip to content

705A. Hulk

implementation, 800, https://codeforces.com/problemset/problem/705/A

Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings.

Hulk likes the Inception so much, and like that his feelings are complicated. They have n layers. The first layer is hate, second one is love, third one is hate and so on...

For example if n = 1, then his feeling is "I hate it" or if n = 2 it's "I hate that I love it", and if n = 3 it's "I hate that I love that I hate it" and so on.

Please help Dr. Banner.

Input

The only line of the input contains a single integer n (1 ≤ n ≤ 100) — the number of layers of love and hate.

Output

Print Dr.Banner's feeling in one line.

Examples

input

1

output

I hate it

input

2

output

I hate that I love it

input

3

output

I hate that I love that I hate it

2020fall-cs101-郭冠廷,

python
say = []
for i in range(int(input())):
    say.append(['I hate', 'I love'][i % 2])
print(" that ".join(say), end=" it\n")
python
n = int(input())
 
l = ""
for i in range(1,n):
    if i%2 == 0:
        l += " that I hate"
    else:
        l += " that I love"
 
print("I hate" + l + " it")

2020fall-cs101-成泽凯,解题思路:

”I hate that”和”I love that”用 while来输出,最后根据 n的奇偶来判断输出”I love it”还是”I hate it”

python
n = int(input())
a = n
while n > 1:
    print("I hate that", end=" ")
    n -= 1
    if n > 1:
        print("I love that", end=" ")
        n -= 1

if a%2 == 0:
    print("I love it")
else:
    print("I hate it")

2021fall-cs101,黄靖涵。https://codeforces.com/problemset/problem/705/A

python
n = int(input())

def f(n):
    if n==1:
        return "I hate it"
    if n%2 == 1:
        return f(n-1)[:-2] + "that I hate it"
    if n%2 == 0:
        return f(n-1)[:-2] + "that I love it"

print(f(n))

思考:

1)递归

2)异或操作(异或也叫半加运算,其运算法则相当于不带进位的二进制加法):二进制下用1 表示真,0 表示假。则异或的运算法则为:0⊕0=0,1⊕0=1,0⊕1=1,1⊕1=0(即,同为 0,异为 1)

python
n = int(input())
f = 1
str = 'I hate it'

for x in range(1, n):
    if f^1:
        str = str.replace('it', 'that I hate it')
    else:
        str = str.replace('it', 'that I love it')
    
    f ^= 1

print(str)